Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::interprocess] Do I need to use lock before allocate shared memory?
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-12-21 02:55:51


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net