boost-interprocess

boost::interprocess scoped_allocator AND Containers of containers NOT in shared memory

谁说我不能喝 提交于 2020-01-09 08:04:29
问题 I have a similar question as before in boost::interprocess Containers of containers NOT in shared memory and How to I create a boost interprocess vector of interprocess containers but this time I like to use my class, which uses a scoped_allocator, also on the heap and shared memory. The solution to my first question was to use a template class with an allocator type In my second previous question it turned out that using a scoped_allocator together with a container of containers within the

boost::interprocess scoped_allocator AND Containers of containers NOT in shared memory

℡╲_俬逩灬. 提交于 2020-01-09 08:03:40
问题 I have a similar question as before in boost::interprocess Containers of containers NOT in shared memory and How to I create a boost interprocess vector of interprocess containers but this time I like to use my class, which uses a scoped_allocator, also on the heap and shared memory. The solution to my first question was to use a template class with an allocator type In my second previous question it turned out that using a scoped_allocator together with a container of containers within the

boost::interprocess scoped_allocator AND Containers of containers NOT in shared memory

南笙酒味 提交于 2020-01-09 08:03:27
问题 I have a similar question as before in boost::interprocess Containers of containers NOT in shared memory and How to I create a boost interprocess vector of interprocess containers but this time I like to use my class, which uses a scoped_allocator, also on the heap and shared memory. The solution to my first question was to use a template class with an allocator type In my second previous question it turned out that using a scoped_allocator together with a container of containers within the

Boost interprocess flat_map operator[] compilation errors

隐身守侯 提交于 2020-01-06 19:05:29
问题 I'm building some wrapper over the boost::interprocess::flat_map, the problem is, that i'm unable to use operator[] or at for some reason. When i'm using find or insert it compiles succesfully. typedef boost::interprocess::managed_shared_memory::segment_manager SegmentManager; typedef boost::interprocess::allocator<char, SegmentManager> CharAllocator; typedef boost::interprocess::basic_string<char, std::char_traits<char>, CharAllocator> ShmString; typedef short KeyType; typedef ShmString

Maps of maps allocated in shared memory

前提是你 提交于 2020-01-02 08:22:54
问题 Inside a boost::interprocess::managed_shared_memory , I am trying to create boost::unordered_map inside another boost::unordered_map as value, having key as std::string for both maps. This Map in Map inside a shared memory segment gets accessed by two different processes fetch values from both outer & inner maps. Below is my implementation & want to know if this is possible/right way or any other better way possible? boost::interprocess::managed_shared_memory segment(boost::interprocess::open

boost::interprocess::managed_shared_memory: Grow(): Memory Reused?

风流意气都作罢 提交于 2019-12-24 13:55:55
问题 I am using boost::interprocess::managed_shared_memory. Initially I allocate say X mb memory. When process ran out of memory, we grow the memory by a fixed value (say Y mb, perform unmap-> grow()-> map) While growing, if contiguous memory is not available then a new chunk with X+Y mb is allocated with a different base address. What happens to previously allocated X mb chunk? Does boost take care of deleting it since it is already unmapped and no process is referring to it? 回答1: Shared memory

When boost library “interprocess” defines a named_mutex do those named_mutexes work properly between different processes, or only with threads?

橙三吉。 提交于 2019-12-24 05:32:13
问题 I think I must be assuming something from the name boost::interprocess that is not true. The documents repeat that named_mutex is global here. I am unable to make it work though. Two copies of the same executable should be run at the same time, and I expect that a named mutex in a library named boost::interprocess might actually BLOCK sometimes. It doesn't. It also doesn't prevent data file corruption in the code below. Here's some code from the boost docs: #include <boost/interprocess/sync

boost interprocess map with int and string

戏子无情 提交于 2019-12-23 14:45:32
问题 I have the following code that saves a map into shared memory using boost interprocess using namespace boost::interprocess; //Shared memory front-end that is able to construct objects //associated with a c-string. Erase previous shared memory with the name //to be used and create the memory segment at the specified address and initialize resources shared_memory_object::remove("MySharedMemory"); try{ managed_shared_memory segment (create_only ,"MySharedMemory" //segment name ,655360); /

C++ allocators, specifically passing constructor arguments to objects allocated with boost::interprocess::cached_adaptive_pool

北城余情 提交于 2019-12-23 08:59:40
问题 This is an embarrassing question, but even the well-written documentation provided with boost.interprocess hasn't been enough for me to figure out how to do this. What I have is a cached_adaptive_pool allocator instance, and I want to use it to construct an object, passing along constructor parameters: struct Test { Test(float argument, bool flag); Test(); }; // Normal construction Test obj(10, true); // Normal dynamic allocation Test* obj2 = new Test(20, false); typedef managed_unique_ptr<

spsc_queue over shared_memory

随声附和 提交于 2019-12-22 08:36:52
问题 I tried several hours, and this problem almost drives me crazy. I want create a spsc_queue over shared memory, and each element in the queue is a mq_item_t structure below. typedef struct _mq_item_t{ mq_item_type type; union { struct{ log_level_t level; char * text; } log; struct{ char * control; size_t control_size; char * payload; size_t payload_size; } error; struct{ char * channel; char * control; size_t control_size; char * payload; size_t payload_size; } data; }; } mq_item_t; Then I