boost-interprocess

Estimating size required for memory mapped boost rtree

狂风中的少年 提交于 2021-02-10 15:01:03
问题 We have a scenario where we dynamically grow a memory mapped file used for boost's r-tree geometric index. We also make use of boost's interprocess memory mapped file api's. Mechanics are already sorted out in terms of unmapping the file, growing, and remapping - this all works. Thus far we've tried overestimating the size with a factor 10 of the inherent size of our coordinates, which works but is grossly over-estimated when inspecting with du . Is there some way to predict (worst-case or

Why does boost::interprocess::managed_shared_memory throw a boost::interprocess_exception upon construction?

ⅰ亾dé卋堺 提交于 2021-02-10 07:26:08
问题 In the code below, I'm trying to initialize a managed_shared_memory object. When the constructor is invoked I see the below error message - terminate called after throwing an instance of 'boost::interprocess::interprocess_exception' what(): boost::interprocess_exception::library_error Aborted why is this exception being thrown? I'm running this on an ubuntu 16.04 linux OS, compiled the program using g++ 9.3.0. Boost version 1.58.0 struct test_obj { size_t x; size_t y; uint8_t buf[32]; bool is

How to get information about free memory from /dev/shm

风流意气都作罢 提交于 2021-01-28 08:00:28
问题 I need a way in C or C++ to get the free memory available from /dev/shm . Note that on my ARM architecure on Linux, unfortunately, ipcs reports a wrong max. available memory information, but df -h correctly gives me the current available memory from tmpfs . The problem is that I am trying to allocate shared memory via boost::interprocess::shared_memory_object::truncate , but this function does not throw when the memory is not available. This problem is not apparently in boost::interprocess ,

Mocking a boost shared memory derived class with gtest

强颜欢笑 提交于 2021-01-28 02:54:34
问题 I have a simple CPP class storing some configuration of my project. This class is stored using boost interprocess shared memory, and so can be accessed from different processes running on my server. Now, I would like to run some tests on my program- so I wish to mock the functionality of my shared-memory-object. In order to do that with gtest, I've created a base configuration class, which my mock class and my shared memory class will derive from. In order to use gtest correctly, the base's

unable to construct runtime boost spsc_queue with runtime size parameter in shared memory

主宰稳场 提交于 2021-01-27 22:18:28
问题 I want to make a lock free ring buffer in shared memory using runtime specified maximum number of entries. I am basing my code off an example I found in GitHub. I successfully created a lock free ring buffer in shared memory using this code. In my case, I need to specify the maximum number of entries that the ring buffer can accept at runtime construction and not at compile time per the example. The call to construct the shm::ring_buffer in the example is shown below. namespace bip = boost:

Using STL containers for boost::interprocess::managed_shared_memory

孤街醉人 提交于 2020-01-21 18:53:51
问题 Consider the following situation: class Helper { public: // Getters and setters are present! private: int i; std::map<int, boost::interprocess::managed_shared_memory> shm; } int main() { boost::interprocess::managed_shared_memory shmInfo(boost::interprocess::open_or_create, "Test", 1024); boost::interprocess::map<int, Helper> myMap = shmInfo.construct< boost::interprocess::map<int, Helper> >("Memory"); } myMap (which is a map of int and Helper ) is constructed on the shared_memory. In turn, I

Boost Interprocess named_mutex semaphore file permissions [duplicate]

佐手、 提交于 2020-01-17 00:41:56
问题 This question already has answers here : POSIX shared memory and semaphores permissions set incorrectly by open calls (2 answers) Closed 2 years ago . I am creating my shared memory using the below, trying either to open or create and setting unrestricted permissions. void createMemory(const int numBytes) { permissions perm; perm.set_unrestricted(); segment.reset(new managed_shared_memory(open_or_create, memory_name, numBytes, 0, perm)); // Exception throw on this line mutex.reset(new named

Example of how to use boost upgradeable mutexes

僤鯓⒐⒋嵵緔 提交于 2020-01-09 19:15:21
问题 I have a multithreaded server application that needs mutex locks over some shared memory. The shared memory are basically sTL maps etc. Much of the time I'm just reading from the map. But, I also need to occasionally add to it. e.g. typedef std::map MessageMap; MessageMap msgmap; boost:shared_mutex access_; void ProcessMessage(Message* message) { // Access message... read some stuff from it message->... UUID id = message->GetSessionID(); // Need to obtain a lock here. (shared lock? multiple

Example of how to use boost upgradeable mutexes

坚强是说给别人听的谎言 提交于 2020-01-09 19:14:58
问题 I have a multithreaded server application that needs mutex locks over some shared memory. The shared memory are basically sTL maps etc. Much of the time I'm just reading from the map. But, I also need to occasionally add to it. e.g. typedef std::map MessageMap; MessageMap msgmap; boost:shared_mutex access_; void ProcessMessage(Message* message) { // Access message... read some stuff from it message->... UUID id = message->GetSessionID(); // Need to obtain a lock here. (shared lock? multiple