boost :: condition :: timed_wait的用法示例 [英] Usage example of boost::condition::timed_wait
本文介绍了boost :: condition :: timed_wait的用法示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人举了一个如何最轻松地使用boost :: condition :: timed_wait的示例吗? 此处,此处和
Does someone have an example of how to most easily use boost::condition::timed_wait? There are some threads on the topic here, here and here, but none feature a working example. And boost doc is as usual quite sparse.
推荐答案
Actually, I finally found a link with full example here. With a bit of adapting, this seems to be the call.
boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds(35000);
boost::mutex::scoped_lock lock(the_mutex);
if(the_condition_variable.timed_wait(lock,timeout,&CondFulfilled))
{
<cond fulfilled code>
}
else
{
<timeout code>
}
bool CondFulfilled() { ... }
这篇关于boost :: condition :: timed_wait的用法示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文