更新时间:2021-11-04 04:53:45
我觉得好,跨平台相当于win32的事件是的的boost ::条件的,所以你的code可能是这个样子:
I think a good, cross-platform equivalent to win32 events is boost::condition, so your code could look something like this:
void foo()
{
boost::mutex mtxWait;
boost::condition cndSignal;
bCall(boost::bind(&bar, mtxWait, cndSignal));
boost::mutex::scoped_lock mtxWaitLock(mtxWait);
cndSignal.wait(mtxWait); // you could also use cndSignal.timed_wait() here
}
void bar(boost::mutex& mtxWait, boost::condition& cndSignal)
{
doSomething();
cndSignal.notify_one();
}