Boost.Interprocess is a part of the C++ Boost library. It simplifies the use of common interprocess communication and synchronization mechanisms.
Questions tagged [boost-interprocess]
371 questions
9
votes
3 answers
Create a locked file with boost::interprocess::file_lock
I'd like to use boost::interprocess::file_lock to ensure that files that are written to a directory x by process P1 are not read by process P2 until they are complete. To do this, I'd like to have P1 lock the files with…

Edward Loper
- 15,374
- 7
- 43
- 52
9
votes
1 answer
Compatibility of boost::interprocess::managed_shared_memory between various versions of boost
Are there any explicit compatibility guarantees that boost::interprocess::managed_shared_memory would work across different boost versions? I'm planning to use it to share an integer or ten between multiple processes (which will essentially act as…

Eugene
- 7,180
- 1
- 29
- 36
9
votes
3 answers
Create a shared-memory vector of strings
I am trying to create a class managing a shared-memory vector of (std)strings.
typedef boost::interprocess::allocator shmem_allocator;
typedef…

emesx
- 12,555
- 10
- 58
- 91
9
votes
1 answer
How do I take ownership of an abandoned boost::interprocess::interprocess_mutex?
My scenario: one server and some clients (though not many). The server can only respond to one client at a time, so they must be queued up. I'm using a mutex (boost::interprocess::interprocess_mutex) to do this, wrapped in a…

Pedro d'Aquino
- 5,130
- 6
- 36
- 46
9
votes
2 answers
Synchronized stored procedure execution in mysql
I have a stored procedure in mysql thats to perform a task that needs to be synchronized such that if two application calls the stored procedure, only one can access a section of code to perform the task, keeping the other one to get blocked until…

Flying Dutchman
- 145
- 1
- 2
- 8
8
votes
1 answer
Destroying a shared std::vector in another process
I'm trying to transfer a std::vector to a newly forked process via Boost.Interprocess, so that the child process takes ownership of it and destroy it. Retrieving and reading the vector works, however I'm getting an access violation upon…

Quentin
- 62,093
- 7
- 131
- 191
8
votes
2 answers
Deleting boost interprocess_mutex when other process might be using it
I'm trying to use interprocess_mutex with managed_windows_shared_memory. In my project, multiple processes create an instance of class A in the following code.
using namespace boost::interprocess;
class A
{
managed_windows_shared_memory* _shm;
…

nglee
- 1,913
- 9
- 32
8
votes
2 answers
Read and remove first (or last) line from txt file without copying
I wanna read and remove the first line from a txt file (without copying, it's a huge file).
I've read the net but everybody just copies the desired content to a new file. I can't do that.
Below a first attempt. This code will be stucked in a loop as…

user1587451
- 978
- 3
- 15
- 30
8
votes
3 answers
Does std::vector satisfy the container requirements for Boost.Interprocess allocators?
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…

Gabor Marton
- 2,039
- 2
- 22
- 33
8
votes
1 answer
Interprocess reader/writer lock with Boost
This thread is gold when it comes to explaining how to implement reader/writer locks with Boost. It seems relatively simple and I really love it but it also seems to be using a non-named lock and I need an interprocess solution (doesn't need to be…

wpfwannabe
- 14,587
- 16
- 78
- 129
7
votes
6 answers
Is boost::interprocess::shared_ptr threadsafe (and interprocess-safe)?
I want to share data between threads, and have it automatically deleted when the last user is done with it. This seems to work, most of the time, using boost::interprocess::shared_ptr in a boost::fixed_managed_shared_memory segment: but not…

James
- 24,676
- 13
- 84
- 130
7
votes
2 answers
C++ allocators, specifically passing constructor arguments to objects allocated with boost::interprocess::cached_adaptive_pool
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…

porgarmingduod
- 7,668
- 10
- 50
- 83
7
votes
1 answer
How can I return an opaque handle (void* or dword) that can be cast back to a value element stored in a boost::interprocess map?
I am a bit confused by the heap and by-value-versus-by-reference semantics involved in putting a std::string key and a large struct value into a container like boost::interprocess::map.
Here is my situation, and some typedefs I'm using:
typedef…

Warren P
- 65,725
- 40
- 181
- 316
7
votes
5 answers
Is it possible to store polymorphic class in shared memory?
Suppose I have class Base and Derived : public Base.
I have constructed a shared memory segment using boost::interprocess library. Is it possible to have code similar to this:
Base* b = new Derived();
write(b); //one app writes
Base* b2 = read(b);…

Queequeg
- 2,824
- 8
- 39
- 66
7
votes
1 answer
Shared map with boost::interprocess
I have a simple requirement that might be tough to solve. I did find some leads like this or this but I can't seem to readilly use them. The former doesn't even translate into buildable code for me. I am not experienced with Boost to just write this…

wpfwannabe
- 14,587
- 16
- 78
- 129