[boost::interprocess] Do I need to use lock before allocate shared memory?

Hi, Do I need to use lock before allocate shared memory? I have two processes that will allocate string to the same shared memory, do I need to use lock? Thanks. -- View this message in context: http://old.nabble.com/-boost%3A%3Ainterprocess--Do-I-need-to-use-lock-before... Sent from the Boost - Users mailing list archive at Nabble.com.

El 19/12/2009 16:04, blp330 escribió:
Hi,
Do I need to use lock before allocate shared memory?
I have two processes that will allocate string to the same shared memory, do I need to use lock?
No, you don't need a lock when allocating raw memory ("managed_shared_memory.allocated()") or constructing objects ("managed_shared_memory.construct<>"). Once constructed, if two threads use the same objects, you will need to use a lock, just like a std::vector shared by two threads. Best, Ion
participants (2)
-
blp330
-
Ion Gaztañaga