inline IVCamSource::~IVCamSource() { //done using it, kill the seg_service stopThread = true; if (camThread.joinable()) camThread.join(); TerminateProcessByName(L"seg_service.exe"); }
average(){ sum = 0; delete_thread_run = true; life = chrono::seconds(10); del = thread(&average::deleteOldData, this); if(del.joinable()) del.detach(); }
void operator()(thread& t) { if (t.joinable()) { t.join(); } }
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'; }
void operator()(thread& t) { t.interrupt(); if (t.joinable()) { t.join(); } }
void StopReceivingMessages() { if (SetEvent(stopRunning)) { messageThread.join(); } else { cerr << "SetEvent failed: " << GetLastError() << "\n"; messageThread.detach(); } }
void join() { if(!thread_.joinable()) return; should_stop_ = true; thread_.join(); }
void SwitcherData::Stop() { if (th.joinable()) { { lock_guard<mutex> lock(m); stop = true; } cv.notify_one(); th.join(); } }
void stop() { if(thread_.joinable()) { { lock_guard lock{m_}; stop_ = true; } cond_.notify_all(); thread_.join(); } }
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); } }
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); }
void stop() { if(!thread_.joinable()) return; should_stop_ = true; }
void SC_LanguageClient::shutdownRuntime() { cleanup_OSC(); #if __APPLE__ gResyncThread.detach(); // leak! #endif }
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; }
bool test_A3_c() { #ifdef A3_c stop_thread(); return (!T.joinable()); #else return false; #endif }
~Actor() // <------------ PATCH { execJobSync([this]()->int { d_keepWorkerRunning = false; return 0; }); d_worker.join(); }
void rng_finilize() { rng_producer_done = true; rng_producer_thread.join(); /* Cleanup */ curandDestroyGenerator(gen); cudaFree(devData); }
C_LINKAGE SC_API_EXPORT void unload(InterfaceTable *inTable) { inputThreadRunning = false; uiListenThread.join(); #ifndef _WIN32 if (d) XCloseDisplay(d); #endif }
string CriticalSection::thread_id(thread& t) { string id; stringstream s; s << t.get_id(); s >> id; return id; }
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; }
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; }
namespace IPC { thread messageThread; HANDLE stopRunning; static void MessageThread(Application *app) { while (true) { // Quit if we were requested to. if (WaitForSingleObject(stopRunning, 0) != WAIT_TIMEOUT) return; try { MessageQueue mq("BunnymodXT-TASView"); vector<char> buf(256); DWORD bytesRead; while (true) { if (mq.timed_read(buf, 1s, bytesRead, stopRunning)) app->ParseMessage(buf, bytesRead); // Quit if we were requested to. if (WaitForSingleObject(stopRunning, 0) != WAIT_TIMEOUT) return; } } catch (const exception& ex) { // Wait 1s before trying again. Quit if we were requested to at any point during this waiting. cerr << "Exception: " << ex.what() << "\n"; if (WaitForSingleObject(stopRunning, 1000) != WAIT_TIMEOUT) return; } } } void StartReceivingMessages(Application *app) { stopRunning = CreateEvent(NULL, TRUE, FALSE, NULL); if (!stopRunning) throw runtime_error("CreateEvent failed: "s + to_string(GetLastError()) + "\n"s); messageThread = thread(MessageThread, app); } void StopReceivingMessages() { if (SetEvent(stopRunning)) { messageThread.join(); } else { cerr << "SetEvent failed: " << GetLastError() << "\n"; messageThread.detach(); } } }
void startSim(int* common,int hold1,int hold2,int playerNum,SimType type) { stopAndGetRes(); while(running.load()) { this_thread::sleep_for(std::chrono::milliseconds(2)); } std::lock_guard<std::mutex> lck (mtx); sum=win=0; stop=false; simThread=move(thread(work,this,common,(int)type,hold1,hold2,playerNum)); simThread.detach(); }
void init(void) { if (currentStage != Stage::NOT_INITIALIZED) throw ShmemAlreadyInitializedException(); shmemBuffer = new char[SHMEM_BUF_SIZE]; strncpy(shmemBuffer, "INIT", SHMEM_BUF_SIZE); agentThread = thread(agent); agentThread.detach(); while (!isMsgEqualTo("ACK")); currentStage = Stage::ACTIVE; }
void stop_log_rotation() { // if no log rotation active, quit. if (!thread_running) return; // join the log rotation thread. lock.lock(); thread_running = false; cond.signal(); lock.unlock(); log_rotate_thread.join(); // we will continue logging to the same location, but we will // delete the symlink unlink(symlink_name.c_str()); }
void SipTransport::sendAxoMessage(const CmdQueueInfo &info, const string& envelope) { LOGGER(DEBUGGING, __func__, " -->"); #if !defined(EMSCRIPTEN) if (!sendThread.joinable()) { unique_lock<mutex> lck(threadLock); if (!sendThread.joinable()) { sendingActive = true; sendThread = thread(runSendQueue, sendAxoData_, this); } lck.unlock(); } #else sendingActive = true; #endif unique_lock<mutex> listLock(sendListLock); // Store all relevant data to send a message in a structure, queue the message // info structure. shared_ptr<SendMsgInfo> msgInfo = make_shared<SendMsgInfo>(); msgInfo->recipient = info.queueInfo_recipient; msgInfo->deviceId = info.queueInfo_deviceId; msgInfo->envelope = envelope; uint64_t typeMask = (info.queueInfo_transportMsgId & MSG_TYPE_MASK) >= GROUP_MSG_NORMAL ? GROUP_TRANSPORT : 0; msgInfo->transportMsgId = info.queueInfo_transportMsgId | typeMask; sendMessageList.push_back(msgInfo); runSend = true; sendCv.notify_one(); listLock.unlock(); #if defined(EMSCRIPTEN) runSendQueue(sendAxoData_, this); #endif LOGGER(DEBUGGING, __func__, " <--"); }
void runnable_pair_test(runnable & a, runnable & b) { cerr << "Entering runnable_pair_test" << endl; static thread ut1, ut2; ut1.start(a); ut2.start(b); ut1.join(); ut2.join(); };
void begin_log_rotation(std::string _log_file_name, size_t _log_interval, size_t _truncate_limit) { if (_truncate_limit == 0) throw "Truncate limit must be >= 1"; stop_log_rotation(); // set up global variables log_base_name = _log_file_name; log_interval = _log_interval; truncate_limit = _truncate_limit; log_counter = 0; symlink_name = log_base_name; thread_running = true; log_rotate_thread.launch(log_rotation_background_thread); }
/** * This static method joins the invoking thread with the other * thread object. This thread will not return from the join * routine until the other thread complets it run. */ void thread::join(thread& other) { void *status = NULL; // joint the first element int error = 0; if(other.active()) { error = pthread_join( other.m_p_thread, &status); if (status != NULL) { const char* strstatus = (const char*) status; throw strstatus; } } if(error) { std::cout << "Major error in join" << std::endl; std::cout << "pthread_join() returned error " << error << std::endl; exit(EXIT_FAILURE); } } // end of join
void interrupt() { ECTO_LOG_DEBUG("interrupting %p", this); runner.interrupt(); ECTO_LOG_DEBUG("interrupt %p done", this); }