Re: [Boost-users] Mutex synchronised wrapper class for boost::interprocess vector of strings

"It's not an easy task. You should catch the exception and then notify all connected processes that should disconnected from the segment (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." OK Ion, thank you for that, I see.... 1. Can I ask what mechanism you would suggest for notifying the other processes to disconnect before the grow() operation? 2. Considering how to deal with the issue of dynamically growing a shared memory vector where there is one producer process and several consumers; I hit upon the notion of having the producer process use a std::vector to conventionally store data and then using a boost shared memory segment to store a pointer to the std::vector. Consumer processes would access the boost shared memory to retrieve the pointer value thus enabling access to the std::vector data store in the producer process. This, I hoped, might remove the complexities associated with dynamically growing a shared memory segment? The big question is: would it work? Would this be a valid means of interprocess communication? Or fraught with complexities? Thanks, Riskybiz.

El 09/07/2013 12:17, Riskybiz escribió:
“It's not an easy task. You should catch the exception and then notify all connected processes that should disconnected from the segment (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.”
OK Ion, thank you for that, I see……..
1.Can I ask what mechanism you would suggest for notifying the other processes to disconnect before the grow() operation?
A condition variable or semaphore could do the work, but all processes should check it periodically.
2.Considering how to deal with the issue of dynamically growing a shared memory vector where there is one producer process and several consumers; I hit upon the notion of having the producer process use a std::vector to conventionally store data and then using a boost shared memory segment to store a pointer to the std::vector. Consumer processes would access the boost shared memory to retrieve the pointer value thus enabling access to the std::vector data store in the producer process. This, I hoped, might remove the complexities associated with dynamically growing a shared memory segment? The big question is: _would it work_? Would this be a valid means of interprocess communication? Or fraught with complexities?
That wouldn't work. The memory where std::vector is stored is not accesible to other processes. Only memory explicitly shared (via managed_shared_memory, or lower level shared_memory_object) is accesible to other processes. I'm afraid that what you are trying to achieve is very complex. I have never tried to do it so I'm afraid you won't find many people to guide you in this issue. Good luck. Ion
participants (2)
-
Ion Gaztañaga
-
Riskybiz