boost :: shared_ptr引用?

时间:2012-10-26 11:46:06

标签: boost synchronization boost-asio shared-ptr

我需要类似的东西:

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");
}

1 个答案:

答案 0 :(得分:1)

是的,这是安全的,因为post复制了它的论点(我想你的意思是io_service_.post())。 请参阅文档here

但在致电_class.release()后,!!_class始终为false,因此while(_class)永远不会执行循环体。