boost-interprocess

std::list in a boost::interprocess::managed_shared_memory

六眼飞鱼酱① 提交于 2019-12-11 13:06:47
问题 Recently I got schooled and learnt the proper way of having a unordered_map inside a boost::interprocess::managed_shared_memory segment. So far so good, but I will need to add a few more STL containers. Ideally, I would want to be able to follow the same for any STL container. Right now I'm in need of a std::list. I can't make it work. I can make a std::vector work, though. std::vector The following code works: #include <vector> #include <boost/interprocess/managed_shared_memory.hpp>

sharing a custom struct using boost::interprocess

心不动则不痛 提交于 2019-12-11 10:18:32
问题 I need to allocate a user defined struct in shared memory using boost's managed_shared_memory but I am not sure how to go about this correctly. It appears that the key to getting this to work correctly is the use of custom allocators. I have successfully been able to make this work with a simple POD uint64_t type, however things become more involved when I try to put more complex types in shared memory. An example of a simple struct I would like to place in shared memory would be something

Instantiating class with custom allocator in shared memory

北城余情 提交于 2019-12-11 06:07:14
问题 I'm pulling my hair due to the following problem: I am following the example given in boost.interprocess documentation to instantiate a fixed-size ring buffer buffer class that I wrote in shared memory. The skeleton constructor for my class is: template<typename ItemType, class Allocator > SharedMemoryBuffer<ItemType, Allocator>::SharedMemoryBuffer( unsigned long capacity ){ m_capacity = capacity; // Create the buffer nodes. m_start_ptr = this->allocator->allocate(); // allocate first buffer

Message passing between two programs

此生再无相见时 提交于 2019-12-11 03:35:56
问题 Currently I have two standalone C++ programs, a master and a slave. The master writes some data to shared memory, using boost::interprocess , and then launches the slave, which is able to read from the memory. What I would like to do is to have the slave constantly running, and for the master to send a message to the slave when the memory has been written to and is ready to be read from. The only way I can think to achieve the same thing is for the slave to constantly check the shared memory

Boost interprocess unordered_map compilation

早过忘川 提交于 2019-12-10 10:07:23
问题 I'm using boost 1.53 and GCC 4.1.2 . I've tried to use boost unordered_map in some tests (documentation says, that it should work with shared memory), but i'm unable to compile my code. With interprocess::map instead of unordered everything is ok. Typedefs: typedef boost::interprocess::allocator<char, SegmentManager> CharAllocator; typedef boost::interprocess::basic_string<char, std::char_traits<char>, CharAllocator> ShmString; typedef ShmString HashKeyType; //ComplexType is a wrapper for

Can Boost Container vector manage memory through non raw pointers?

为君一笑 提交于 2019-12-09 13:01:21
问题 I have a pointer-like struct that goes in the place of a pointer. The difference with a pointer is that it has extra information that the (also special) allocator can use to deallocate the memory. This pointer-like structure works well for all basic uses. I can allocate and deallocate memory, dereferrence, increment, -> , etc. Now I want to use this pointers to be managed by a STL-like container. Early on, I realized that STL vector basically cannot handle non-raw pointers. T* is too hard

Boost interprocess Win32, x64

南笙酒味 提交于 2019-12-08 05:34:13
问题 I want to communicate between different platforms using boost interprocess. I am using vc12 and boost 1.58 on windows 7. My code below is a very simple example, that should work. But it doesn't for communications between diffrent platforms... If I create msm in x64 and open in win32, the process stuck at a lock at function try_based_lock in boost/int/sync/detail/common_algorithms.hpp In the other way around: win32 create, x64 open: the process crashes at name_length in segment_manager_helper

Boost Interprocess share memory deletion, permissions and output files

喜你入骨 提交于 2019-12-08 05:33:43
问题 I am using Boost Interprocess library to share memory between two processes. I am using the following to allocate shared memory block, an attached vector, named mutex and a named condition variable: using ShmemAllocator = allocator<T, managed_shared_memory::segment_manager>; using MyVector = vector<T, ShmemAllocator>; segment.reset(new managed_shared_memory(create_only, blockName, numBytes)); const ShmemAllocator alloc_inst(segment->get_segment_manager()); vec = segment->construct<MyVector>

Using a circular buffer on disk

僤鯓⒐⒋嵵緔 提交于 2019-12-08 05:19:11
问题 I was trying to create a memory-mapped circular buffer on disk using Boost, and I read this answer: https://stackoverflow.com/a/29265629/8474732 However, I have a hard time reading the circular buffer that was written. I tried to do a push_back on the "instance" variable, now the instance has size 1. Great. But how would I read the contents back? Or push_back additional elements at a later time? Creating another instance from the same allocator and mmf shows that the instance has size 0. I

boost::interprocess::named_mutex vs CreateMutex

喜夏-厌秋 提交于 2019-12-07 06:52:08
问题 I want to switch from CreatMutex to boost::interprocess::named_mutex to limit my application to a single instance. Both methods works when the application runs and ends just fine. However, the lock is not released when the application crashes and using boost::interprocess::named_mutex . I could resolve that issue by using two name_mutex but I don't really understand the issue. Why is the lock for boost::interprocess::named_mutex not released when the application crashes but it is release with