Reputation: 6625
I'm using Boost::interprocess::message_queue to enable communication between threads on my application. I'm doing so for two reasons. First, because I don't need to directly implement a shared mem. synchronization mechanism and second because I want to model the system this way because in the future it may change to interprocess.
My question is: Is there any more apropriate mechanism to enable interthread communication given this restrictions or I can continue using interprocess queue without fear for 'interprocess overhead'?
Upvotes: 1
Views: 2853
Reputation: 7677
You could use a std::queue
protected by a boost::mutex
& boost::condition_variable
Anthony Williams provides an excellent explanation on how to implement a thread safe queue in his book 'C++ Concurrency in Action'.
Example code is available on his website here:
Just Software Solutions - Implementing a Thread Safe Queue
Upvotes: 2