2

Currently I have two standalone C++ programs, a master and a slave. The master writes some data to shared memory, using boost::interprocess, and then launches the slave, which is able to read from the memory.

What I would like to do is to have the slave constantly running, and for the master to send a message to the slave when the memory has been written to and is ready to be read from.

The only way I can think to achieve the same thing is for the slave to constantly check the shared memory for the presence of an object, and when it is detected read from it and delete it. However, this doesn't seem optimal.

Is there a nicer way of achieving the same thing?


Background: This is a continuation of my previous question here...

4

2 回答 2

1

您可以使用posix 消息队列,或者更好的是boost 消息队列

于 2012-01-17T21:08:46.367 回答
0

Why not have them communicate over a unix domain socket? From the other question, you said you were building this on ubuntu, so that won't work immediately on windows.

Boost has support for this in the boost::asio lib, which I suspect uses named pipe sockets when you compile for windows.

于 2012-01-17T19:08:58.593 回答