I am especially dense about this, but it seems that I am missing an important, basic point or something else, since what I want to do should be general:
I need to create a fixed-size ring buffer object from the manager ( Process M) process . This object has methods write()and read()read / write of the buffer. Read / write methods will be called by independent processes ( Process Rand W)
I implemented a buffer, SharedBuffer<T&>it allocates buffer slots in SHM using boost :: interprocess and works fine within a single process. I read the answers to this question and that one on SO, and also asked my own , but I am still in the dark about how to have different methods of accessing processes from a common object. The Boost document has an example of creating a vector in SHM , which is very similar to what I want, but I want to create an instance of my own class.
My current settings are:
- Use accommodation
newas suggested by Charles B. to my question ; however, he warns that it is not recommended to place non-POD objects in SHM. But my class needs read / write methods, how can I handle them? - Add a dispenser to my class definition, for example. have
SharedBuffer<T&, Alloc>and are executed similarly to the vector example specified in boost. That sounds very complicated. - Change
SharedBufferto the POD class, i.e. get rid of all the methods. But how to synchronize reading and writing between processes?
What am I missing? Fixed-length ring buffers are very common, so either this problem has a solution, or I'm doing something wrong.
source
share