boost-interprocess

Create a shared-memory vector of strings

三世轮回 提交于 2019-11-27 18:19:49
问题 I am trying to create a class managing a shared-memory vector of (std)strings. typedef boost::interprocess::allocator<std::string, boost::interprocess::managed_shared_memory::segment_manager> shmem_allocator; typedef boost::interprocess::vector<std::string, shmem_allocator> shmem_vector; shmem_mgr::shmem_mgr() : shmem_(create_only, SHMEM_KEY, SHMEM_SIZE), allocator_(shmem_.get_segment_manager()) { mutex_ = shmem_.find_or_construct<interprocess_mutex>(SHMEM_MUTEX)(); condition_ = shmem_.find

Storing vector in memory mapped file

半腔热情 提交于 2019-11-27 07:15:59
问题 I am attempting to store a vector of arbitrary elements in a memory mapped file (for now I'm trying to succeed with a vector of ints but it should work with vector of arbitrary objects). I have found plenty of documentation on doing so with shared memory, but not with memory mapped files proper. Since I have successfully made and used R-trees in memory mapped file (like in that example), I tried to replicate the process with vectors, but I guess I am missing some crucial element because it

How can I achieve something similar to a semaphore using boost in c++? [duplicate]

瘦欲@ 提交于 2019-11-27 02:58:01
问题 This question already has an answer here: C++0x has no semaphores? How to synchronize threads? 10 answers I noticed that boost does not seem to support semaphores. What's the easiest way to achieve a similar effect? 回答1: You either need Boost Interprocess semaphore or Boost Thread synchronization primitives. Mutex/Lock and condition are primitives that are commonly used to synchronize access to shared resources across multiple threads of a single process. There are exclusive, readers-writer