Search code examples
c++boostboost-interprocess

How to get know that boost::interprocess::message_queue was removed from system?


I create Sender/Receiver wrapper based on boost::interprocess::message_queue for sending messages from one process and receiving it in another, you can view sources here: https://gist.github.com/onto/c322bb0a33433b775966

There is a problem, if I destruct sender object, message_queue was removed from system, but receiver wasn't notifyed of it. How to fix it?

If message_queue not exists on creating MessageQueueReceiver object it throws an exception, it's normal behaviour for me, but if i remove message_queue from system boost::interprocess::message_queue::receive doesn't throw anything, boost::interprocess::message_queue::timed_receive return false but it just mean that timeout expired.


Solution

  • As a solution, I throw an exception when timeout expired and recreate MessageQueueReceiver object.