【发布时间】:2012-10-26 11:46:06
【问题描述】:
我需要类似的东西:
boost::shared_ptr<A> _class(...);
//Start async operation
boost::aiso::post(_class);
_class.relase();
while(_class) // not working
{
LOG("Wait for aync operation to complete");
}
【问题讨论】:
-
您不能以这种方式等待 async.operation 完成。你的
post是什么?它会发布到另一个线程吗? -
@IgorR。是正确的。您的问题意味着您实际上想要一个同步等待(这很容易实现)。这就是你想要的吗?
-
是的,但我希望条件与 shared_ptr ref_cnt 相关。同时我用信号量实现了这个并解决了这个问题。
标签: boost synchronization boost-asio shared-ptr