本文整理汇总了C++中hpx::lcos::local::condition_variable::wait_for方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable::wait_for方法的具体用法?C++ condition_variable::wait_for怎么用?C++ condition_variable::wait_for使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hpx::lcos::local::condition_variable
的用法示例。
在下文中一共展示了condition_variable::wait_for方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_test
void do_test(void (this_type::*test_func)())
{
Lock lock(m);
locked=false;
done=false;
hpx::thread t(test_func,this);
try
{
{
boost::unique_lock<hpx::lcos::local::mutex> lk(done_mutex);
HPX_TEST(done_cond.wait_for(lk,boost::chrono::seconds(2),
boost::bind(&this_type::is_done,this)));
HPX_TEST(!locked);
}
lock.unlock();
t.join();
}
catch(...)
{
lock.unlock();
t.join();
throw;
}
}
示例2: relative_wait_until_with_predicate
void relative_wait_until_with_predicate()
{
boost::unique_lock<hpx::lcos::local::spinlock> lock(mutex);
if(cond_var.wait_for(lock,boost::posix_time::seconds(5),check_flag(flag)) && flag)
{
++woken;
}
}
示例3: hpx_main
int hpx_main()
{
hpx::id_type here = hpx::find_here();
hpx::id_type there = here;
if (hpx::get_num_localities_sync() > 1)
{
std::vector<hpx::id_type> localities = hpx::find_remote_localities();
there = localities[0];
}
{
increment_action inc;
hpx::apply_colocated(inc, there, here, 1);
}
{
hpx::unique_future<hpx::id_type> inc_f =
hpx::components::new_<increment_server>(there);
hpx::id_type where = inc_f.get();
increment_action inc;
hpx::apply_colocated(inc, where, here, 1);
}
{
hpx::unique_future<hpx::id_type> inc_f =
hpx::components::new_<increment_server>(there);
hpx::id_type where = inc_f.get();
hpx::apply_colocated<increment_action>(where, here, 1);
}
// finalize will synchronize will all pending operations
int result = hpx::finalize();
hpx::util::spinlock::scoped_lock l(result_mutex);
result_cv.wait_for(result_mutex, boost::chrono::seconds(1),
hpx::util::bind(std::equal_to<boost::int32_t>(), boost::ref(final_result), 3));
HPX_TEST_EQ(final_result, 3);
return result;
}