How to use the shared region in append mode
First of all i would like to thank for previous answers. Now i am able to use the shared region to create a map, insert value into shared map and use the shared map. Now moving one step ahead. I am planning to use the shared region in append mode. For instance 1. create shared region if it is not used before // how to check this ? managed_shared_memory segment(create_only,MySharedMemory, 999999999); 2. create map in the region // done 3. open the map and use the map for retrieving and inserting values //done How i can that the given region already allocated to map so that i can insert the value in it otherwise i can create the that region and create tha map and insert the value in the map. Thanks in advance. -- View this message in context: http://www.nabble.com/How-to-use-the-shared-region-in-append-mode-tp25677408... Sent from the Boost - Users mailing list archive at Nabble.com.
I am trying in this way.
I am writing the shared region and its value in a file and read the file in
the map if shared region exits i make the flag = 1 else make the flag =0;
bool flag = 0;
// shared_memory_object::remove(MySharedMemory);
if(flag == 0)
managed_shared_memory segment(create_only,MySharedMemory, 99989);
else
managed_shared_memory segment(open_only ,MySharedMemory);
void_allocator alloc_inst (segment.get_segment_manager()); /
complex_map_type *mymap =
segment.construct
First of all i would like to thank for previous answers. Now i am able to use the shared region to create a map, insert value into shared map and use the shared map. Now moving one step ahead. I am planning to use the shared region in append mode. For instance
1. create shared region if it is not used before // how to check this ? managed_shared_memory segment(create_only,MySharedMemory, 999999999); 2. create map in the region // done 3. open the map and use the map for retrieving and inserting values //done
How i can that the given region already allocated to map so that i can insert the value in it otherwise i can create the that region and create tha map and insert the value in the map.
Thanks in advance.
-- View this message in context: http://www.nabble.com/How-to-use-the-shared-region-in-append-mode-tp25677408... Sent from the Boost - Users mailing list archive at Nabble.com.
manish4gupta wrote:
if(flag == 0) managed_shared_memory segment(create_only,MySharedMemory, 99989); else managed_shared_memory segment(open_only ,MySharedMemory);
Error message: Indexingtest.cpp:41: error: ‘segment’ was not declared in this scope
How can i overcome such pblm.
By reading a good book about C++ :-) You want to learn about scope. Then you have several options. Pointers are one, functions might be another (not sure if managed_shared_memory is copyable). If you go for pointers, familiarize yourself with shared_ptr. Smart pointers are your friends. Regards, Roland
I think it is not copyable so what else can be done? Roland Bock-2 wrote:
manish4gupta wrote:
if(flag == 0) managed_shared_memory segment(create_only,MySharedMemory, 99989); else managed_shared_memory segment(open_only ,MySharedMemory);
Error message: Indexingtest.cpp:41: error: ‘segment’ was not declared in this scope
How can i overcome such pblm.
By reading a good book about C++ :-)
You want to learn about scope. Then you have several options. Pointers are one, functions might be another (not sure if managed_shared_memory is copyable).
If you go for pointers, familiarize yourself with shared_ptr. Smart pointers are your friends.
Regards,
Roland _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/How-to-use-the-shared-region-in-append-mode-tp25677408... Sent from the Boost - Users mailing list archive at Nabble.com.
I found one managed_shared_memory creation constructor. managed_shared_memory segment(open_or_create,MySharedMemory, 99989); Does this mean if there exists a region MySharedMemory ,then open it else create the region "MySharedMemory". But it does not work like this. How can i solve my pblm. manish4gupta wrote:
I think it is not copyable so what else can be done?
Roland Bock-2 wrote:
manish4gupta wrote:
if(flag == 0) managed_shared_memory segment(create_only,MySharedMemory, 99989); else managed_shared_memory segment(open_only ,MySharedMemory);
Error message: Indexingtest.cpp:41: error: ‘segment’ was not declared in this scope
How can i overcome such pblm.
By reading a good book about C++ :-)
You want to learn about scope. Then you have several options. Pointers are one, functions might be another (not sure if managed_shared_memory is copyable).
If you go for pointers, familiarize yourself with shared_ptr. Smart pointers are your friends.
Regards,
Roland _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/How-to-use-the-shared-region-in-append-mode-tp25677408... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
manish4gupta
-
Roland Bock