boostorg / unordered

Boost.org unordered module
http://boost.org/libs/unordered
Boost Software License 1.0
58 stars 59 forks source link

Using concurrent_flat_map with interprocess mapped memory allocator #256

Closed bocharov closed 1 week ago

bocharov commented 1 month ago

Hello,

I have a use case that involves using Boost's concurrent_flat_map with an interprocess mapped memory allocator. My application is designed to be read-heavy with occasional inserts and deletes. It also requires multiple processes (not just threads) to access the container concurrently.

I have two questions:

  1. Is it possible to use concurrent_flat_map with an interprocess mapped memory allocator in such a way that multiple processes can access and modify the map concurrently?
  2. If the above is not feasible, could you recommend an alternative container or approach within Boost that would suit this use case? My primary goals are to minimize synchronization costs and ensure efficient read access across multiple processes.

Thank you for your assistance!

joaquintides commented 4 weeks ago

Yes, it works, see this example:

https://github.com/boostorg/unordered/blob/develop/test/cfoa/interprocess_concurrency_tests.cpp

Note, however, that this feature is not documented, so you would be using it unofficially. We haven't decided yet whether to guarantee it for future releases of the library.