当前位置: 首页>>代码示例>>C++>>正文


C++ future::wait方法代码示例

本文整理汇总了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();
	});
}
开发者ID:TheBlackJokerDevil,项目名称:openclonk,代码行数:11,代码来源:C4Network2UPnPLinux.cpp

示例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;
	}
}
开发者ID:cadet,项目名称:_2RealFramework,代码行数:14,代码来源:BasicBlocksAndCustomTypes.cpp

示例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;
	}
}
开发者ID:BryceMehring,项目名称:Chess,代码行数:18,代码来源:AI.cpp

示例4: schedule

 void schedule(std::weak_ptr<Mailbox>) final {
     promise.set_value();
     future.wait();
     std::this_thread::sleep_for(1ms);
     waited = true;
 }
开发者ID:1SpatialGroupLtd,项目名称:mapbox-gl-native,代码行数:6,代码来源:actor.test.cpp

示例5: wait

 void wait() {
     promise.set_value();
     future.wait();
     std::this_thread::sleep_for(1ms);
     waited = true;
 }
开发者ID:1SpatialGroupLtd,项目名称:mapbox-gl-native,代码行数:6,代码来源:actor.test.cpp

示例6:

 ~ConcurrentAccess() {
     queue_.Push([=]{done_ = true;});
     f_.wait();
 }
开发者ID:ugovaretto,项目名称:cpp11-scratch,代码行数:4,代码来源:task-based-executor-concurrent-generic.cpp


注:本文中的std::future::wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。