本文整理汇总了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();
}
示例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;
}
示例3: join
void join()
{
c2s_.join();
s2c_.join();
if (ep_) {
std::rethrow_exception(ep_);
}
}
示例4: disconnect
void disconnect() {
connected.store(false);
closesocket(sock);
sender.join();
recver.join();
send_queue.clear();
recv_queue.clear();
}
示例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();
}
示例6: StopFakeWork
void StopFakeWork()
{
t0.join();
t1.join();
t2.join();
t3.join();
t42.join();
t43.join();
t44.join();
t45.join();
tlong.join();
}
示例7: stopSignalHandlers
void stopSignalHandlers()
{
#ifdef WIN32
System::sendSignal(::GetCurrentProcessId(), SIGINT);
gThreadMessageLoop.join();
#endif
}
示例8:
~Task()
{
if(_thread.joinable())
{
_thread.join();
}
}
示例9:
~impl()
{
stop();
if( th_.joinable() ) {
th_.join();
}
}
示例10: stop
void stop()
{
assert(_running);
_running = false;
_thread.join();
}
示例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");
}
示例12: join_thread
void join_thread(void)
{
if (super::running.load()) {
super::terminate();
callback_thread.join();
}
}
示例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);
}
示例14: StopEngine
//--------------------------------
void StopEngine()
{
#ifdef USE_THREAD_FOR_INPUT
stop = true;
t.join();
#endif // USE_THREAD_FOR_INPUT
}
示例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
}