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.

有帮助吗?

解决方案

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().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top