Esempio n. 1
0
void UPnP::StopPortmapping()
{
  if (s_thread.joinable())
    s_thread.join();
  s_thread = std::thread(&UnmapPortThread);
  s_thread.join();
}
Esempio n. 2
0
// Called from GUI thread
void Stop()  // - Hammertime!
{
	if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN)
	{
		if (g_EmuThread.joinable())
			g_EmuThread.join();
		return;
	}

	const SCoreStartupParameter& _CoreParameter =
		SConfig::GetInstance().m_LocalCoreStartupParameter;

	g_bStopping = true;

	g_video_backend->EmuStateChange(EMUSTATE_CHANGE_STOP);

	INFO_LOG(CONSOLE, "Stop [Main Thread]\t\t---- Shutting down ----");

	// Stop the CPU
	INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stop CPU").c_str());
	PowerPC::Stop();

	// Kick it if it's waiting (code stepping wait loop)
	CCPU::StepOpcode();

	if (_CoreParameter.bCPUThread)
	{
		// Video_EnterLoop() should now exit so that EmuThread()
		// will continue concurrently with the rest of the commands
		// in this function. We no longer rely on Postmessage.
		INFO_LOG(CONSOLE, "%s", StopMessage(true, "Wait for Video Loop to exit ...").c_str());
		
		g_video_backend->Video_ExitLoop();
	}

	INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping Emu thread ...").c_str());
	
	g_EmuThread.join();	// Wait for emuthread to close.

	INFO_LOG(CONSOLE, "%s", StopMessage(true, "Main Emu thread stopped").c_str());

#ifdef _WIN32
	EmuWindow::Close();
#endif

	// Clear on screen messages that haven't expired
	g_video_backend->Video_ClearMessages();

	// Close the trace file
	Core::StopTrace();
	
	// Reload sysconf file in order to see changes committed during emulation
	if (_CoreParameter.bWii)
		SConfig::GetInstance().m_SYSCONF->Reload();

	INFO_LOG(CONSOLE, "Stop [Main Thread]\t\t---- Shutdown complete ----");
	Movie::Shutdown();
	g_bStopping = false;
}
Esempio n. 3
0
	void join()
	{
		c2s_.join();
		s2c_.join();
		if (ep_) {
			std::rethrow_exception(ep_);
		}
	}
Esempio n. 4
0
	void disconnect() {
		connected.store(false);
		closesocket(sock);

		sender.join();
		recver.join();

		send_queue.clear();
		recv_queue.clear();
	}
 virtual void TearDown() {
   // If a thread has not completed, then continuing will cause the tests to
   // hang forever and could cause issues. If we don't call detach, then
   // std::terminate is called and all threads are terminated.
   // Detaching is non-optimal, but should allow the rest of the tests to run
   // before anything drastic occurs.
   if (m_done1) m_watcher1.join();
   else m_watcher1.detach();
   if (m_done2) m_watcher2.join();
   else m_watcher2.detach();
 }
Esempio n. 6
0
void StopFakeWork()
{
	t0.join();
	t1.join();
	t2.join();
	t3.join();
	t42.join();
	t43.join();
	t44.join();
	t45.join();
	tlong.join();
}
void stopSignalHandlers()
{
#ifdef WIN32
	System::sendSignal(::GetCurrentProcessId(), SIGINT);
	gThreadMessageLoop.join();
#endif
}
Esempio n. 8
0
void
Stop_main()
{
    LOG_INFO("Service stop requested, exiting...");
    vm.Stop();
    main_thread.join();
}
Esempio n. 9
0
 ~Task()
 {
     if(_thread.joinable())
     {
         _thread.join();
     }
 }
Esempio n. 10
0
		~impl()
		{
			stop();
			if( th_.joinable() ) {
				th_.join();
			}
		}
Esempio n. 11
0
        void stop()
        {
            assert(_running);

            _running = false;
            _thread.join();
        }
Esempio n. 12
0
void StopHTTPServer()
{
    LogPrint(BCLog::HTTP, "Stopping HTTP server\n");
    if (workQueue) {
        LogPrint(BCLog::HTTP, "Waiting for HTTP worker threads to exit\n");
        workQueue->WaitExit();
        delete workQueue;
        workQueue = nullptr;
    }
    if (eventBase) {
        LogPrint(BCLog::HTTP, "Waiting for HTTP event thread to exit\n");
        // Give event loop a few seconds to exit (to send back last RPC responses), then break it
        // Before this was solved with event_base_loopexit, but that didn't work as expected in
        // at least libevent 2.0.21 and always introduced a delay. In libevent
        // master that appears to be solved, so in the future that solution
        // could be used again (if desirable).
        // (see discussion in https://github.com/bitcoin/bitcoin/pull/6990)
        if (threadResult.valid() && threadResult.wait_for(std::chrono::milliseconds(2000)) == std::future_status::timeout) {
            LogPrintf("HTTP event loop did not exit within allotted time, sending loopbreak\n");
            event_base_loopbreak(eventBase);
        }
        threadHTTP.join();
    }
    if (eventHTTP) {
        evhttp_free(eventHTTP);
        eventHTTP = 0;
    }
    if (eventBase) {
        event_base_free(eventBase);
        eventBase = 0;
    }
    LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
}
 void join_thread(void)
 {
     if (super::running.load()) {
         super::terminate();
         callback_thread.join();
     }
 }
Esempio n. 14
0
int main()
{
    unsigned char a;
    long long b;
    unsigned char c;
    char d[64];
    unsigned char e;
    signal(SIGINT, sigHandler);
    stop = false;
    counter = std::thread(thrMain);
    while (!stop) {
        //std::cout<<number<<std::endl;
        //printf("%lld\n", number);
        a = 0;
        b = number;
        for (c = 0; c < 63 && b > 0; c++) {
            a = b % 10;
            b /= 10;
            d[c] = a + 48;
        }
        d[c] = '\0';
        for (a = --c; c > a / 2; c--) {
            e = d[c];
            d[c] = d[a-c];
            d[a-c] = e;
        }
        puts(d);
    }
    counter.join();
    usleep(200);
}
Esempio n. 15
0
File: main.cpp Progetto: niklasf/k2
//--------------------------------
void StopEngine()
{
#ifdef USE_THREAD_FOR_INPUT
        stop = true;
        t.join();
#endif // USE_THREAD_FOR_INPUT
}
Esempio n. 16
0
    void join() {
        if (!detached)
            return;

        #if defined(__APPLE__) || defined(__linux__)
            /* Release GIL and disassociate from thread state (which was originally
               associated with the main Python thread) */
            py::gil_scoped_release thread_state(true);

            coro_transfer(&ctx_main, &ctx_thread);
            coro_stack_free(&stack);

            /* Destroy the thread state that was created in mainloop() */
            {
                py::gil_scoped_acquire acquire;
                acquire.dec_ref();
            }
        #endif

        thread.join();
        detached = false;

        #if defined(__APPLE__) || defined(__linux__)
            /* Reacquire GIL and reassociate with thread state
               [via RAII destructor in 'thread_state'] */
        #endif
    }
Esempio n. 17
0
void WebSocketClientUtil::joinThreads()
{
    if ( _subThread->joinable() )
    {
        _subThread->join();
    }
}
Esempio n. 18
0
void WsThreadHelper::joinSubThread()
{
    if (_subThreadInstance->joinable())
    {
        _subThreadInstance->join();
    }
}
Esempio n. 19
0
 ~ScopedThread()
 {
   if (t_.joinable())
   {
     t_.join();
   }
 }
Esempio n. 20
0
void FileServer::stop()
{
	if( _running ) {
		_endThread = true;
		_thread.join();
	}
}
Esempio n. 21
0
	~impl() {
		_cts.cancel();
		if (_jobQueueThread.joinable()) {
			_jobQueueThread.join();
		}
		_ctx = nullptr;
	}
Esempio n. 22
0
void do_final(int code)
{
    aFree(g_PBuff);
    aFree(PTempBuff);

    aFree((void*)map_config.mysql_host);
    aFree((void*)map_config.mysql_database);

    itemutils::FreeItemList();
    battleutils::FreeWeaponSkillsList();
    battleutils::FreeSkillChainDamageModifiers();

    petutils::FreePetList();
    zoneutils::FreeZoneList();
    luautils::free();
    message::close();
    if (messageThread.joinable())
    {
        messageThread.join();
    }

    delete CTaskMgr::getInstance();
    delete CVanaTime::getInstance();

    Sql_Free(SqlHandle);

    timer_final();
    socket_final();
    malloc_final();

    exit(code);
}
void PS3EyeStereoDepthApp::shutdown() {
    stopThreads = TRUE;
    if (calibrationThread.joinable()) {
        calibrationThread.join();
    }
    camPair.stop();
}
Esempio n. 24
0
 ~WSClientImpl() override
 {
     ws_.close({});
     stream_.close();
     work_ = boost::none;
     thread_.join();
 }
Esempio n. 25
0
 ~http_sync_server()
 {
     error_code ec;
     ios_.dispatch(
         [&]{ acceptor_.close(ec); });
     thread_.join();
 }
Esempio n. 26
0
void peterDeJongTeardown( ) {

    shouldRun = false;
    if( updater.joinable( ) )
        updater.join( );

}
Esempio n. 27
0
	void stopConsumerThread(){
		done=true;
		//wakup if sleeping
		cond_var.Signal();
		//wait for termination
		consumerThread.join();
	}
Esempio n. 28
0
	inline engine_t::~engine_t()
	{
		signal([&] {
			running_ = false;
		});

		handle_.join();
	}
Esempio n. 29
0
void ThreadManager::join(std::thread& thread)
{
	if(thread.joinable())
	{
		thread.join();
		unregisterThread();
	}
}
Esempio n. 30
0
		~async_message_loop()
		{
			if(thread.get_id() != std::thread::id()){
				DWORD id = ::GetThreadId(thread.native_handle());
				::PostThreadMessageW(id, WM_QUIT, 0, 0);
				thread.join();
			}
		}