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


C++ thread::join方法代码示例

本文整理汇总了C++中std::thread::join方法的典型用法代码示例。如果您正苦于以下问题:C++ thread::join方法的具体用法?C++ thread::join怎么用?C++ thread::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::thread的用法示例。


在下文中一共展示了thread::join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StopPortmapping

void UPnP::StopPortmapping()
{
  if (s_thread.joinable())
    s_thread.join();
  s_thread = std::thread(&UnmapPortThread);
  s_thread.join();
}
开发者ID:Tinob,项目名称:Ishiiruka,代码行数:7,代码来源:UPnP.cpp

示例2: Stop

// 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;
}
开发者ID:Everscent,项目名称:dolphin-emu,代码行数:60,代码来源:Core.cpp

示例3: join

	void join()
	{
		c2s_.join();
		s2c_.join();
		if (ep_) {
			std::rethrow_exception(ep_);
		}
	}
开发者ID:faithandbrave,项目名称:misc,代码行数:8,代码来源:packet-repeater.cpp

示例4: disconnect

	void disconnect() {
		connected.store(false);
		closesocket(sock);

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

		send_queue.clear();
		recv_queue.clear();
	}
开发者ID:killgxlin,项目名称:boost_network,代码行数:10,代码来源:new_client.cpp

示例5: TearDown

 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();
 }
开发者ID:Talos4757,项目名称:allwpilib,代码行数:11,代码来源:ConditionVariableTest.cpp

示例6: StopFakeWork

void StopFakeWork()
{
	t0.join();
	t1.join();
	t2.join();
	t3.join();
	t42.join();
	t43.join();
	t44.join();
	t45.join();
	tlong.join();
}
开发者ID:zeux,项目名称:microprofile,代码行数:12,代码来源:fakework.cpp

示例7: stopSignalHandlers

void stopSignalHandlers()
{
#ifdef WIN32
	System::sendSignal(::GetCurrentProcessId(), SIGINT);
	gThreadMessageLoop.join();
#endif
}
开发者ID:xiaoxiaokongyi,项目名称:httpserver,代码行数:7,代码来源:SignalHandlers.cpp

示例8:

 ~Task()
 {
     if(_thread.joinable())
     {
         _thread.join();
     }
 }
开发者ID:techmaru,项目名称:Simd,代码行数:7,代码来源:Test.cpp

示例9:

		~impl()
		{
			stop();
			if( th_.joinable() ) {
				th_.join();
			}
		}
开发者ID:LNSEAB,项目名称:mmaccel,代码行数:7,代码来源:file_monitor.cpp

示例10: stop

        void stop()
        {
            assert(_running);

            _running = false;
            _thread.join();
        }
开发者ID:porpoisepor,项目名称:ecst,代码行数:7,代码来源:tp2.cpp

示例11: StopHTTPServer

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");
}
开发者ID:Crinklebine,项目名称:bitcoin,代码行数:33,代码来源:httpserver.cpp

示例12: join_thread

 void join_thread(void)
 {
     if (super::running.load()) {
         super::terminate();
         callback_thread.join();
     }
 }
开发者ID:DSastre,项目名称:supercollider,代码行数:7,代码来源:callback_interpreter.hpp

示例13: main

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);
}
开发者ID:synergiance,项目名称:scratch-pad,代码行数:31,代码来源:main.cpp

示例14: StopEngine

//--------------------------------
void StopEngine()
{
#ifdef USE_THREAD_FOR_INPUT
        stop = true;
        t.join();
#endif // USE_THREAD_FOR_INPUT
}
开发者ID:niklasf,项目名称:k2,代码行数:8,代码来源:main.cpp

示例15: join

    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
    }
开发者ID:Meumeu,项目名称:nanogui,代码行数:27,代码来源:python.cpp


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