Re: [InterProcess] receiving notification when an item is added to the message queue
On 10/07/2020 17:07, Sean Farrow via Boost-users wrote:
> Good afternoon,
> I am looking to use the message queue in the Interprocess library to
> communicate between two Windows processes.
> I was wondering whether there was an in-built mechanism to signal to the
> process reading from the queue that a message is available for consumption.
No, there isn't.
> If there isn’t anything in-built, I was wondering what the best way to
> do this is and whether anybody has any working sample code they would be
> willing to share?
If the notification has to be asynchronous, then you need to use
os-specific mechanism, like signals. If you need to support Windows,
then you need to use windows-specific mechanisms, you can look
alternatives to signals here:
Another way is to launch a background thread and check for an
interprocess-mechanism like a named semaphore or similar and notify
internally your processing thread to check the message queue. Not
simple, but I can't think about any easy alternative.