Boost logo

Boost Users :

Subject: Re: [Boost-users] Mutex synchronised wrapper class for boost::interprocess
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2013-06-27 18:06:55


El 25/06/2013 18:46, Riskybiz escribió:
> What is the best approach to extend a managed_shared_memory_segment? I can
> dynamically add (via write() function) shared vector elements until such
> time as an interprocess_exception boost_interprocess::bad_alloc is thrown;
> when the memory allocated to the shared segment is filled. Is there a way
> to handle this exception so that the segment can be extended with more
> memory and then resume adding data elements to the vector? Or perhaps some
> other way to detect the segment memory is running short and take action to
> extend it?

It's not an easy task. You should catch the exception and then notify
all connected processes that should disconnected from the segmenet (as
only offline growing is supported). After that a process can call "grow"
to try extend the segment. Then, all processes can attach to the newly
grown segment.

Think of that as a complex binary file that must be extended and
internal structures changed. All users should close the file, the file
should be changed by a process and then all users can start using the
file again.

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