Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-04-29 11:26:51


Jason Sachs wrote:
> OK, let me ask a simpler question:
>
> If I have a structure S which contains a shared memory allocator, can
> that structure be safely stored in shared memory? (e.g. if I construct S
> in one process, use the memory allocator to construct some other pointer
> p in shared memory, then locate S in another process and use the memory
> allocator to destroy pointer p, will that work properly, or have I
> invited Disaster?)

If the structure stores the allocator and all other pointers to any type
(say X) inside the structure are of the same type as
boost::pointer_to_other<allocator::pointer, X>::type that structure is
mappable in different addresses in different processes.

E.g.: Shared memory containers are classes that store a shared memory
allocator to allocate dynamically memory from the shared memory segment.
Any internal pointers of those containers (for example an internal
pointer pointing to the memory allocated with the shared memory
allocator) is the same type of smart pointer (offset_ptr<T>) as
allocator::pointer.

Regards,

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