mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-25 18:22:19 +00:00
Fixed C++0x and MacOS X bugs
[SVN r52418]
This commit is contained in:
@@ -13,22 +13,44 @@
|
||||
#include <boost/interprocess/managed_shared_memory.hpp>
|
||||
#include <boost/interprocess/allocators/node_allocator.hpp>
|
||||
#include <cassert>
|
||||
//<-
|
||||
#include "../test/get_process_id_name.hpp"
|
||||
//->
|
||||
|
||||
using namespace boost::interprocess;
|
||||
|
||||
int main ()
|
||||
{
|
||||
//Remove shared memory on construction and destruction
|
||||
struct shm_destroy
|
||||
struct shm_remove
|
||||
{
|
||||
shm_destroy() { shared_memory_object::remove("MySharedMemory"); }
|
||||
~shm_destroy(){ shared_memory_object::remove("MySharedMemory"); }
|
||||
//<-
|
||||
#if 1
|
||||
shm_remove() { shared_memory_object::remove(test::get_process_id_name()); }
|
||||
~shm_remove(){ shared_memory_object::remove(test::get_process_id_name()); }
|
||||
#else
|
||||
//->
|
||||
shm_remove() { shared_memory_object::remove("MySharedMemory"); }
|
||||
~shm_remove(){ shared_memory_object::remove("MySharedMemory"); }
|
||||
//<-
|
||||
#endif
|
||||
//->
|
||||
} remover;
|
||||
|
||||
//Create shared memory
|
||||
//<-
|
||||
#if 1
|
||||
managed_shared_memory segment(create_only,
|
||||
test::get_process_id_name(), //segment name
|
||||
65536);
|
||||
#else
|
||||
//->
|
||||
managed_shared_memory segment(create_only,
|
||||
"MySharedMemory", //segment name
|
||||
65536);
|
||||
//<-
|
||||
#endif
|
||||
//->
|
||||
|
||||
//Create a node_allocator that allocates ints from the managed segment
|
||||
//The number of chunks per segment is the default value
|
||||
|
||||
Reference in New Issue
Block a user