我需要类似的东西:
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");
}
答案 0 :(得分:1)
是的,这是安全的,因为post
复制了它的论点(我想你的意思是io_service_.post()
)。
请参阅文档here。
但在致电_class.release()
后,!!_class
始终为false
,因此while(_class)
永远不会执行循环体。