void killWorkerThread() { mRunThread = false; if ( mWorkerThread.joinable() ) { mWorkerThread.join(); } }
~ThreadRunner() noexcept try { g_quit = true; if (thread_.joinable()) thread_.join(); } catch (std::exception& e) { cybozu::PutLog(cybozu::LogError, "ThreadRunner: error: %s", e.what()); }
~progressIndicatorThreadWrapper() { m_stopCondition.store( true ); if( m_thread.joinable() ) { m_thread.join(); } }
~TetrisGame_impl() { if(runner.joinable()) { gameOver(); pauseCondition.notify_all(); runner.join(); } }
void quit() { if (!_thread.joinable()) return; _commandQueue.autoPriorityEmplace<TMQ::CloseQueue>(); _run = false; _thread.join(); _release(); }
void stop() noexcept { if( !th_.joinable() ) { return; } exit_flag_ = true; event_.set(); }
//-------------------------------- void QuitCommand(std::string in) { UNUSED(in); #ifdef USE_THREAD_FOR_INPUT if(busy || t.joinable()) StopEngine(); #endif // USE_THREAD_FOR_INPUT quit = true; }
~Impl() { { std::unique_lock<std::mutex> lock(m_queueGuard); std::queue<Data>().swap(m_queue); } Stop(); if (m_thread.joinable()) m_thread.join(); }
// 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(); } }
void HiresTexture::Shutdown() { if (s_prefetcher.joinable()) { s_textureCacheAbortLoading.Set(); s_prefetcher.join(); } s_textureMap.clear(); s_textureCache.clear(); }
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(); }
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(); }
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(); } ); }
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); } }
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(); } }
bool NTServerManager::StartProcessingPackets() { static std::thread PacketThread; if (!PacketThread.joinable()) { PacketThread = std::thread(PacketProcessingThread); PacketThread.detach(); return true; } return false; }
bool IsGPUThread() { const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; if (_CoreParameter.bCPUThread) { return (g_EmuThread.joinable() && (g_EmuThread.get_id() == std::this_thread::get_id())); } else { return IsCPUThread(); } }
void run() { isPaused=false; if(!runner.joinable()) // Thread not yet initialized { timeCount=0; newPiece(); isContinuing=true; runner = std::thread( &TetrisGame_impl::threadFunc, this); } pauseCondition.notify_one(); }
void jni_fini() { stop_loop = true; main_loop.stop(); try { if (net_thread.joinable()) { net_thread.join(); } } catch (...) { } }
void stop() { std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); if (!is_running_) { return; } if (thread_.joinable()) { async([&]() { requires_stop_ = true; }); thread_.join(); } is_running_ = false; }
/** * Close the task. This will raise in this thread any exception the * task generated in the other thread. Calling this function is * optional, because the destructor will also call this function. * But because it can throw an exception, it is better to call it * explicitly. */ void close() { // If an exception happened in the task, re-throw // it in this thread. This will block if the task // isn't finished. if (m_future.valid()) { m_future.get(); } // Make sure task is done. if (m_thread.joinable()) { m_thread.join(); } }
//-------------------------------- int main(int argc, char* argv[]) { UNUSED(argc); UNUSED(argv); #ifdef TUNE_PARAMETERS for(int i = 0; i < NPARAMS; ++i) param.push_back(1); #endif InitEngine(); tt.clear(); max_search_depth = max_ply; time_remains = 300000000; time_base = 300000000; time_inc = 0; moves_per_session = 0; max_nodes_to_search = 0; time_command_sent = false; char in[0x4000]; while(!quit) { if(!std::cin.getline(in, sizeof(in), '\n')) std::cin.clear(); if(CmdProcess((std::string)in)) { // NiCheGoNeDeLaYem! } else if(!busy && LooksLikeMove((std::string)in)) { if(!MakeMoveFinaly(in)) std::cout << "Illegal move" << std::endl; else if(!force) { #ifdef USE_THREAD_FOR_INPUT if(t.joinable()) t.join(); t = std::thread(MainSearch); #else MainSearch(); #endif // USE_THREAD_FOR_INPUT } } else std::cout << "Unknown command: " << in << std::endl; } if(busy) StopEngine(); }
//-------------------------------- void AnalyzeCommand(std::string in) { UNUSED(in); force = false; infinite_analyze = true; #ifdef USE_THREAD_FOR_INPUT if(t.joinable()) t.join(); t = std::thread(MainSearch); #else MainSearch(); #endif // USE_THREAD_FOR_INPUT }
void TimeoutFunction(const char* MyString) { printf("Startet %s\n", MyString); StartTime = GetTickCount(); PrintString = MyString; running = false; if (InternThread.joinable()) { InternThread.join(); } running = true; InternThread = std::thread(MyPrint); }
void vc4cl::deinitEventQueue() { std::lock_guard<std::mutex> guard(queuesMutex); numCommandQueues--; if(numCommandQueues == 0 && eventHandler.joinable()) { #ifdef DEBUG_MODE std::cout << "[VC4CL] Stopping queue handler thread..." << std::endl; #endif // wake up event handler, so we can stop it eventAvailable.notify_all(); eventHandler.join(); } }
void peterDeJongSetup( ) { // std::cout << "DeJong parameters: " << a << ", " << b << ", " << c << ", " << d << std::endl; shouldRun = false; if( updater.joinable( ) ) updater.join( ); for( int i = 0; i < height * width; ++i ) image[ i ] = 0.0; shouldRun = true; updater = std::thread( peterDeJongFun ); }
void do_final(int code) { message_server_close(); if (messageThread.joinable()) { messageThread.join(); } Sql_Free(SqlHandle); timer_final(); socket_final(); exit(code); }
/* ------------------------------------------------------------------------------------------------ * The server was shutdown and this plug-in must terminate as well. */ static void OnServerShutdown(void) { // The server may still send callbacks _Clbk->OnServerInitialise = nullptr; _Clbk->OnServerShutdown = nullptr; _Clbk->OnServerFrame = nullptr; // Tell the announce thread to stop g_Announce = false; // Wait for the announce thread to finish if (g_Thread.joinable()) { g_Thread.join(); } // Flush any remaining messages FlushMessages(); }
//-------------------------------- void GoCommand(std::string in) { UNUSED(in); if(busy) return; if(uci) UciGoCommand(in); else force = false; #ifdef USE_THREAD_FOR_INPUT if(t.joinable()) t.join(); t = std::thread(MainSearch); #else MainSearch(); #endif // USE_THREAD_FOR_INPUT }
// This is called from the GUI thread. See the booting call schedule in // BootManager.cpp bool Init() { const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; if (s_emu_thread.joinable()) { if (IsRunning()) { PanicAlertT("Emu Thread already running"); return false; } // The Emu Thread was stopped, synchronize with it. s_emu_thread.join(); } Core::UpdateWantDeterminism(/*initial*/ true); INFO_LOG(OSREPORT, "Starting core = %s mode", _CoreParameter.bWii ? "Wii" : "GameCube"); INFO_LOG(OSREPORT, "CPU Thread separate = %s", _CoreParameter.bCPUThread ? "Yes" : "No"); Host_UpdateMainFrame(); // Disable any menus or buttons at boot g_aspect_wide = _CoreParameter.bWii; if (g_aspect_wide) { IniFile gameIni = _CoreParameter.LoadGameIni(); gameIni.GetOrCreateSection("Wii")->Get("Widescreen", &g_aspect_wide, !!SConfig::GetInstance().m_SYSCONF->GetData<u8>("IPL.AR")); } s_window_handle = Host_GetRenderHandle(); // Start the emu thread s_emu_thread = std::thread(EmuThread); return true; }