本文整理汇总了C++中std::future::wait方法的典型用法代码示例。如果您正苦于以下问题:C++ future::wait方法的具体用法?C++ future::wait怎么用?C++ future::wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::future
的用法示例。
在下文中一共展示了future::wait方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void C4Network2UPnPP::ClearMappings()
{
action = std::async([this, action = std::move(action)]() {
action.wait();
for (auto mapping : added_mappings)
RemovePortMapping(mapping);
added_mappings.clear();
});
}
示例2: handleFuture
void handleFuture( std::future< _2Real::BlockResult > &obj, std::string const& info = "" )
{
obj.wait();
_2Real::BlockResult val = obj.get();
switch ( val )
{
case _2Real::BlockResult::CARRIED_OUT:
std::cout << "---- " << info << " was carried out" << std::endl;
break;
case _2Real::BlockResult::IGNORED:
std::cout << "---- " << info << " was ignored" << std::endl;
break;
}
}
示例3: WaitForFuture
void AI::WaitForFuture(const std::future<void>& fut, bool bPondering)
{
std::uint64_t timePerMove = GetTimePerMove();
if(bPondering)
{
timePerMove /= 2;
}
// Wait until the thread finishes or it gets timed out
if(fut.wait_for(std::chrono::nanoseconds(timePerMove)) == std::future_status::timeout)
{
// If the thread did not finish execution, signal the thread to exit, and wait till the thread exits.
m_bStopMinimax = true;
fut.wait();
m_bStopMinimax = false;
}
}
示例4: schedule
void schedule(std::weak_ptr<Mailbox>) final {
promise.set_value();
future.wait();
std::this_thread::sleep_for(1ms);
waited = true;
}
示例5: wait
void wait() {
promise.set_value();
future.wait();
std::this_thread::sleep_for(1ms);
waited = true;
}
示例6:
~ConcurrentAccess() {
queue_.Push([=]{done_ = true;});
f_.wait();
}