boost-interprocess

Is boost::interprocess threadsafe?

一世执手 提交于 2019-12-07 05:30:03
问题 Currently, I have 2 processes that communicate using the message_queue and shared_memory form boost. Everything work as attended. Now I need to make one of this process multi threaded (thanks to boost again), and I was wondering if I need to use protection mechanism between the threads (such as mutex), or if the boost::interprocess library already provides a protection mechanism ? I did not find any info on that on the boost documentation. By the way I'm using boost 1.40. Thanks in advance.

How do I debug or fix the endless loop and heap corruption issue involving boost::interprocess managed_shared_memory?

自作多情 提交于 2019-12-06 21:33:28
问题 I have the following "first-chance exception" message which is coming from a DLL I wrote which is running inside an executable that I did not write. That is, the DLL is a plugin. The first time this exception fires, an attempt to open a shared memory map file is failing. If I ignore first chance exceptions and just run, the application freezes or crashes eventually. First-chance exception at 0x76a7c41f in notmyexe.exe: Microsoft C++ exception: boost::interprocess::interprocess_exception at

Boost interprocess unordered_map compilation

旧城冷巷雨未停 提交于 2019-12-06 00:39:30
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 internal interprocess::map typedef ComplexType HashMappedType; typedef std::pair<const ShmString,

spsc_queue over shared_memory

送分小仙女□ 提交于 2019-12-05 13:32:37
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 have following code to create the spsc_queue . typedef boost::interprocess::managed_windows_shared_memory

Mapping non-contiguous blocks from a file into contiguous memory addresses

时光怂恿深爱的人放手 提交于 2019-12-05 10:38:12
问题 I am interested in the prospect of using memory mapped IO, preferably exploiting the facilities in boost::interprocess for cross-platform support, to map non-contiguous system-page-size blocks in a file into a contiguous address space in memory. A simplified concrete scenario: I've a number of 'plain-old-data' structures, each of a fixed length (less than the system page size.) These structures are concatenated into a (very long) stream with the type & location of structures determined by the

Is boost::interprocess threadsafe?

ⅰ亾dé卋堺 提交于 2019-12-05 09:38:13
Currently, I have 2 processes that communicate using the message_queue and shared_memory form boost. Everything work as attended. Now I need to make one of this process multi threaded (thanks to boost again), and I was wondering if I need to use protection mechanism between the threads (such as mutex), or if the boost::interprocess library already provides a protection mechanism ? I did not find any info on that on the boost documentation. By the way I'm using boost 1.40. Thanks in advance. The shared resources from boost::interprocess (shared memory, etc) require that you provide the

Does std::vector satisfy the container requirements for Boost.Interprocess allocators?

偶尔善良 提交于 2019-12-05 04:07:20
In boost::interprocess documentation it is said as requirement for containers to be stored in shared memory: STL containers may not assume that memory allocated with an allocator can be deallocated with other allocators of the same type. All allocators objects must compare equal only if memory allocated with one object can be deallocated with the other one, and this can only tested with operator==() at run-time. Containers' internal pointers should be of the type allocator::pointer and containers may not assume allocator::pointer is a raw pointer. All objects must be constructed-destroyed via

Read access violation for memory mapped vector in debug mode

馋奶兔 提交于 2019-12-04 20:45:38
While attempting to use boost::interprocess for storing a std::vector in a memory mapped file, I am getting the exception Exception thrown: read access violation. when I try to push back on a loaded vector, but only in debug mode . This minimal example code (written by @sehe) is retrieved from https://stackoverflow.com/a/29602884/2741329 , and it crashes on MSVC14 in debug mode and executed more than once: #include <boost/interprocess/managed_mapped_file.hpp> namespace bi = boost::interprocess; int main() { std::string vecFile = "vector.dat"; bi::managed_mapped_file file_vec(bi::open_or_create

Allocating a user defined struct in shared memory with boost::interprocess

泄露秘密 提交于 2019-12-04 16:46:34
I am trying to use boost::interprocess to allocate a very simple data structure in shared memory but I cannot quite figure out how to use the boost interprocess allocators to perform the memory allocations/deallocations within the shared memory segment which I allocate as follows using namespace boost::interprocess; shared_memory_object::remove("MySharedMem"); mSharedMemory = std::make_unique<managed_shared_memory>( open_or_create, "MySharedMem", 65536); I previously asked a similar question but unfortunately I never got any answers. MyStruct below is essentially an array with a length field

What does boost interprocess file_lock actually do with the target file?

▼魔方 西西 提交于 2019-12-04 14:01:14
问题 I've done some reading about boost::interprocess::file_lock and it seems to do pretty much what I'm after (support shareable and exclusive locking, and being unlocked if the process crashes or exits). One thing I'm not sure about though, is what does it do to the file? Can I use for example a file of 0 bytes long? Does boost::interprocess write anything into it? Or is its presence all the system cares about? I've been using boost::interprocess now for some time to reliably memory map a file