I want to share data between threads, and have it automatically deleted when the last user is done with it. This seems to work, most of the time, using boost::interpro
boost::shared_ptr
is not interprocess safe, so whether it is multithread safe in this context is moot. (This statement assumes that BOOST_SP_DISABLE_THREADS
has not been #defined
for the program's operation.)
boost::interprocess::shared_ptr
is, in its very nature, designed to be cross-process safe, as well as multithread safe in its nature. When the last reference goes out of scope, the pointed-at object can be cleaned up. Obviously, this cleaning up happens within the bounds of the shared memory segment used for the object.
Since boost::shared_ptr
uses a lock-free counting mechanism at version 1.33.0 on many platforms, it is unlikely except by the remotest of chances that cross-process deletion of an object in a shared_memory
segment would succeed, and does not appear to be supported functionality by the Boost maintainers.