0

I succesfully compiled the Creating vectors in shared memory example from Boost. I'm uncertain if insertions into the constructed vector from multiple processes are safe (automatically synchronized intern). The documentation talks about Synchronization guarantees but this only refers the creation/search/destruction of the shared memory.

Do you know if I have to synchronize vector accesses (insertions, deletion, iteration) manually with e.g. scoped_lock<named_mutex>?

Christian Ammer
  • 7,464
  • 6
  • 51
  • 108

1 Answers1

4

The object you created is a std::vector, so boost can't have added any synchronization to the standard library class. Just like any other std::vector, you'll have to synchronize it manually.

Useless
  • 64,155
  • 6
  • 88
  • 132
  • It's the first time I'm dealing with shared memory and was not sure if there's something going on behind the scenes (particularly the `ShmemAllocator` with which the vector was generated). Thank you for clarification. – Christian Ammer Aug 04 '14 at 13:05
  • There is indeed - the allocator itself is synchronized, so that different processes can allocate from the same segment. It just doesn't help you out with the container-level semantics above that. – Useless Aug 04 '14 at 13:28