boostboost-interprocess

Is there a built-in concurrency control in boost::interprocess::message_queue?


In a multiple producer-single consumer setting, is there a built-in concurrency control mechanism among the producer processes that are calling send() on the message_queue?

What happens if there are multiple instances of the consumer processes all calling receive() on the message_queue?


Solution

  • To the question whether message_queue is thread-safe, the answer is yes.

    message_queue is implemented in terms of shared_memory_object using some control structures (ipcdetail::mq_hdr_t) which include synchronization primitives (like interprocess_mutex).

    These are used to prevent unguarded concurrent access.