At first I will outline the domain with 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 don't care about final size of an underlying file, but I cannot foresight this value. Is there any boost mechanism, which will handle resizing an underlying file? Or I have to catch bip::bad_alloc and care about this by my own?
Read this this section of the docs.
You have the static member function grow()
that may be what you need:
bip::managed_mapped_file::grow("./file", extra_bytes);
But you have to be sure that nobody is using the file, that's why they call it off-line growing. And that may not be possible depending on the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With