本文整理汇总了C++中thread类的典型用法代码示例。如果您正苦于以下问题:C++ thread类的具体用法?C++ thread怎么用?C++ thread使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了thread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: average
average(){
sum = 0;
delete_thread_run = true;
life = chrono::seconds(10);
del = thread(&average::deleteOldData, this);
if(del.joinable()) del.detach();
}
示例2: operator
void operator()(thread& t)
{
if (t.joinable())
{
t.join();
}
}
示例3: print_id
void print_id(thread& t)
{
if (t.get_id()==thread::id{})
cout << "t not joinable\n";
else
cout << "t's id is " << t.get_id() << '\n';
}
示例4: join
void join()
{
if(!thread_.joinable())
return;
should_stop_ = true;
thread_.join();
}
示例5: stop
void stop()
{
if(thread_.joinable())
{
{
lock_guard lock{m_};
stop_ = true;
}
cond_.notify_all();
thread_.join();
}
}
示例6: beat
void beat()
{
static ServerInfo info;
info = Server->getInfo();
static thread hb;
if(hb.timed_join(milliseconds(0)))
{
hb = thread( doHeartBeat,std::ref(info));
Tasks->callLater(60000,beat);
}
}
示例7: obs_module_unload
void obs_module_unload(void)
{
#ifdef USE_QT_LOOP
BrowserShutdown();
#else
if (manager_thread.joinable()) {
while (!QueueCEFTask([] () {CefQuitMessageLoop();}))
os_sleep_ms(5);
manager_thread.join();
}
#endif
os_event_destroy(cef_started_event);
}
示例8: stop
void stop()
{
if(!thread_.joinable())
return;
should_stop_ = true;
}
示例9: run
uint32_t run()
{
m_actual->m_state = thread::STARTED;
m_actual->m_return = m_actual->run();
m_actual->m_state = thread::COMPLETED;
return m_actual->m_return;
}
示例10: test_A3_c
bool test_A3_c() {
#ifdef A3_c
stop_thread();
return (!T.joinable());
#else
return false;
#endif
}
示例11: rng_finilize
void rng_finilize()
{
rng_producer_done = true;
rng_producer_thread.join();
/* Cleanup */
curandDestroyGenerator(gen);
cudaFree(devData);
}
示例12: thread_id
string CriticalSection::thread_id(thread& t)
{
string id;
stringstream s;
s << t.get_id();
s >> id;
return id;
}
示例13:
JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_OICCoordinatorStop
(JNIEnv *env, jobject obj)
{
jint result = 0;
//terminate Thread
if (ocProcessThread.joinable())
{
threadRun = false;
ocProcessThread.join();
}
else
{
result = (jint)HOSTING_THREAD_ERROR;
return result;
}
result = (jint)OICStopCoordinate();
return result;
}
示例14: return
JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingTerminate
(JNIEnv *env, jobject obj)
{
if (OCStop() != OC_STACK_OK)
{
return (jint)OCSTACK_ERROR;
}
//terminate Thread
if (ocProcessThread.joinable())
{
threadRun = false;
ocProcessThread.join();
}
else
{
return (jint)HOSTING_THREAD_ERROR;
}
return (jint)OCSTACK_OK;
}
示例15:
inline IVCamSource::~IVCamSource()
{
//done using it, kill the seg_service
stopThread = true;
if (camThread.joinable()) camThread.join();
TerminateProcessByName(L"seg_service.exe");
}