Increase interprocessor dispenser - manage file size

First I will describe the domain with the source.

namespace bip=boost::interprocess;

typedef bip::allocator<int, bip::managed_mapped_file::segment_manager> allocator;
typedef bip::vector<int, allocator> vector;

bip::managed_mapped_file m_file(open_or_create, "./file", constant_value);    
bip::allocator alloc(m_file.get_segment_manager());
bip::vector *vec = m_file.find_or_construct<vector>("vector")(alloc);

I do not need the final size of the base file, but I cannot foresee this value. Is there a boost mechanism that will handle resizing the base file? Or do I need to catch bip :: bad_alloc and take care of this myself?

+5
source share
1 answer

Read this section of the documentation.

You have a static member function grow()that you might need:

bip::managed_mapped_file::grow("./file", extra_bytes);

But you must be sure that no one is using the file, so they call it offline. And this may not be possible depending on the problem.

+6
source

All Articles