gpt4 book ai didi

c++ - boost::condition::timed_wait 的使用示例

转载 作者:IT老高 更新时间:2023-10-28 22:37:19 24 4
gpt4 key购买 nike

有人有如何最轻松地使用 boost::condition::timed_wait 的示例吗?该主题有一些线程here , herehere ,但没有一个具有工作示例。而且 boost doc 像往常一样非常稀疏。

最佳答案

实际上,我终于找到了一个完整示例的链接here .稍微适应一下,这似乎是电话。

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() { ... }

关于c++ - boost::condition::timed_wait 的使用示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7078511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com