本文整理汇总了C++中std::thread::joinable方法的典型用法代码示例。如果您正苦于以下问题:C++ thread::joinable方法的具体用法?C++ thread::joinable怎么用?C++ thread::joinable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::thread
的用法示例。
在下文中一共展示了thread::joinable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: killWorkerThread
void killWorkerThread()
{
mRunThread = false;
if ( mWorkerThread.joinable() )
{
mWorkerThread.join();
}
}
示例2: catch
~ThreadRunner() noexcept
try
{
g_quit = true;
if (thread_.joinable()) thread_.join();
} catch (std::exception& e) {
cybozu::PutLog(cybozu::LogError, "ThreadRunner: error: %s", e.what());
}
示例3:
~progressIndicatorThreadWrapper()
{
m_stopCondition.store( true );
if( m_thread.joinable() )
{
m_thread.join();
}
}
示例4:
~TetrisGame_impl()
{
if(runner.joinable())
{
gameOver();
pauseCondition.notify_all();
runner.join();
}
}
示例5: quit
void quit()
{
if (!_thread.joinable())
return;
_commandQueue.autoPriorityEmplace<TMQ::CloseQueue>();
_run = false;
_thread.join();
_release();
}
示例6: stop
void stop() noexcept
{
if( !th_.joinable() ) {
return;
}
exit_flag_ = true;
event_.set();
}
示例7: QuitCommand
//--------------------------------
void QuitCommand(std::string in)
{
UNUSED(in);
#ifdef USE_THREAD_FOR_INPUT
if(busy || t.joinable())
StopEngine();
#endif // USE_THREAD_FOR_INPUT
quit = true;
}
示例8: lock
~Impl()
{
{
std::unique_lock<std::mutex> lock(m_queueGuard);
std::queue<Data>().swap(m_queue);
}
Stop();
if (m_thread.joinable())
m_thread.join();
}
示例9: cleanupThread
// Helper function for cleaning up the thread in use
inline void cleanupThread(std::thread &t)
{
if (t.joinable())
{
t.join();
}
else if (t.get_id() != std::thread::id())
{
t.detach();
}
}
示例10: Shutdown
void HiresTexture::Shutdown()
{
if (s_prefetcher.joinable())
{
s_textureCacheAbortLoading.Set();
s_prefetcher.join();
}
s_textureMap.clear();
s_textureCache.clear();
}
示例11: Shutdown
void Shutdown()
{
// During shutdown DXGI expects us to handle some messages on the UI thread.
// Therefore we can't immediately block and wait for the emu thread to shut
// down, so we join the emu thread as late as possible when the UI has already
// shut down.
// For more info read "DirectX Graphics Infrastructure (DXGI): Best Practices"
// on MSDN.
if (s_emu_thread.joinable())
s_emu_thread.join();
}
示例12: StopDVDThread
static void StopDVDThread()
{
ASSERT(s_dvd_thread.joinable());
// By setting s_DVD_thread_exiting, we ask the DVD thread to cleanly exit.
// In case the request queue is empty, we need to set s_request_queue_expanded
// so that the DVD thread will wake up and check s_DVD_thread_exiting.
s_dvd_thread_exiting.Set();
s_request_queue_expanded.Set();
s_dvd_thread.join();
}
示例13: start
void start(boost::string_ref dir, std::function< bool( boost::string_ref) >&& f)
{
if( th_.joinable() ) {
return;
}
f_ = std::move( f );
dir_ = winapi::directory_handle( dir, FILE_SHARE_READ, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED );
exit_flag_ = false;
th_ = std::thread( [this] { this->thread_main(); } );
}
示例14: guard
void vc4cl::initEventQueue()
{
std::lock_guard<std::mutex> guard(queuesMutex);
numCommandQueues++;
if(!eventHandler.joinable())
{
#ifdef DEBUG_MODE
std::cout << "[VC4CL] Starting queue handler thread..." << std::endl;
#endif
eventHandler = std::thread(runEventQueue);
}
}
示例15: IsGPUThread
bool IsGPUThread()
{
const SConfig& _CoreParameter = SConfig::GetInstance();
if (_CoreParameter.bCPUThread)
{
return (s_emu_thread.joinable() && (s_emu_thread.get_id() == std::this_thread::get_id()));
}
else
{
return IsCPUThread();
}
}