Edgepo1nt
Edgepo1nt

Reputation: 303

Boost message queues between processes that have more than a single thread (boost threads)

I develop an interactive protocol on C++ between N processes that communicate with each other via boost message_queue queues. One of the processes has 2 execution threads, a main thread that uses the queues, and a "helper" thread which listens to messages that are accepted on one of the queues, and if needed, sends new messages to other processes by using the queue.

Does boost message queues support usage of multiple threads with them in terms of synchronization between the threads, sleep of a single thread in case waiting for a message, etc? The threads library I use is the boost thread library.

Upvotes: 0

Views: 1441

Answers (1)

Tanner Sansbury
Tanner Sansbury

Reputation: 51871

I am not entirely sure I understand the question, but Boost.Interprocess's message_queue is thread-safe. The receive() member function allows for the caller to block, waiting for a message. Reading with timeouts can be accomplished by using timed_receive().

Upvotes: 1

Related Questions