June 23rd, 2010, 08:46 AM
I've been experimenting with boost::interprocess::managed_shared_memory, but one thing I can't seem to get to cooperate for me is boost::interprocess::string, and I'm having a lot of trouble finding any sort of tutorial online on how to use it.
With other containers like vector and map I know I have to:
typedef allocator<ThingToStore, managed_shared_memory::segment_manager> ThingToStoreAllocator;
typedef vector<ThingToStore, ThingToStoreAllocator> ThingVector;
But I'm having trouble figuring how to how to set up an interprocess string.
const ThingToStoreAllocator *thingAllocator = new ThingAllocator(sharedSpace.get_segment_manager());
m_thingVector = sharedSpace.construct<ThingVector>("m_thingVector")(*thingAllocator);
I've been trying by just typedefing boost::interprocess::string to BoostString and using that as an interprocess variable in the shared space. Interestingly enough for a long time I thought this was working just fine, but now I'm discovering it seems like if I stick to a small number of characters it works (the other process can read it just fine) but if I go larger I'm writing beyond what the other process thinks it is and segfaults.
Anyone have any experience in this?
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.