A quick design question about C ++ container classes in shared memory

I am writing a simple wrapper around a vector: vector forprocess container to implement a ring buffer in shared memory (shm) for IPC. Suppose it bufis an instance RingBuffercreated in shm. Now in his ctor bufhe selects a private data element boost::interprocess::vectorfor storing values, for example. m_data. My question is: I think it m_datashould also be created in shared memory. But is this a necessity?

What happens if the bufone created in shm itself allocates standard memory, i.e. using new. Does this work out on a bunch of calling process? I do not think that bufstands out there, as it turns out that there is distributed a data element that is private to the object, and not on the process heap. I'm confused.

+3
source share
1 answer

boost::interprocess::vectoraccepts the type of dispenser as a template parameter. This allocator must be allocated from the shared memory (see. Usage examples).

new, , . , boost::interprocess::vector .

ctor, buf boost:: interprocess:: vector data​​i >

. ++ "" . , . , , , 4- , .

, , , ,

, , . new ( ), . ( , , Boost - API), . , , , , .

+3

Source: https://habr.com/ru/post/1737272/


All Articles