コード例 #1
0
ファイル: realsense.cpp プロジェクト: AnthonySuper/obs-studio
	inline IVCamSource::~IVCamSource()
	{
		//done using it, kill the seg_service
		stopThread = true;
		if (camThread.joinable()) camThread.join();
		TerminateProcessByName(L"seg_service.exe");
	}
コード例 #2
0
 average(){
     sum = 0;
     delete_thread_run = true;
 	life = chrono::seconds(10);
     del = thread(&average::deleteOldData, this);
     if(del.joinable()) del.detach();
 }
コード例 #3
0
 void operator()(thread& t)
 {
   if (t.joinable())
   {
     t.join();
   }
 }
コード例 #4
0
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';
}
コード例 #5
0
 void operator()(thread& t)
 {
   t.interrupt();
   if (t.joinable())
   {
     t.join();
   }
 }
コード例 #6
0
ファイル: IPC.cpp プロジェクト: YaLTeR/TASView
	void StopReceivingMessages()
	{
		if (SetEvent(stopRunning)) {
			messageThread.join();
		} else {
			cerr << "SetEvent failed: " << GetLastError() << "\n";
			messageThread.detach();
		}
	}
コード例 #7
0
ファイル: tiobench.cpp プロジェクト: rodrigostrauss/tio
	void join()
	{
		if(!thread_.joinable())
			return;

		should_stop_ = true;

		thread_.join();

	}
コード例 #8
0
void SwitcherData::Stop()
{
	if (th.joinable()) {
		{
			lock_guard<mutex> lock(m);
			stop = true;
		}
		cv.notify_one();
		th.join();
	}
}
コード例 #9
0
 void stop()
 {
     if(thread_.joinable())
     {
         {
             lock_guard lock{m_};
             stop_ = true;
         }
         cond_.notify_all();
         thread_.join();
     }
 }
コード例 #10
0
ファイル: Heartbeat.cpp プロジェクト: TheArchives/ArMCpp
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);
    }
}
コード例 #11
0
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);
}
コード例 #12
0
ファイル: tiobench.cpp プロジェクト: rodrigostrauss/tio
	void stop()
	{
		if(!thread_.joinable())
			return;

		should_stop_ = true;
	}
コード例 #13
0
void SC_LanguageClient::shutdownRuntime()
{
	cleanup_OSC();
#if __APPLE__
	gResyncThread.detach(); // leak!
#endif
}
コード例 #14
0
ファイル: thread.cpp プロジェクト: kurtism-lmb/u50s
	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;
	}
コード例 #15
0
ファイル: A3.cpp プロジェクト: DerNerger/CppProjects
bool test_A3_c() {
#ifdef A3_c
    stop_thread();
    return (!T.joinable());   
#else
    return false;
#endif
}
コード例 #16
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 ~Actor() // <------------ PATCH
 {
     execJobSync([this]()->int
     {
         d_keepWorkerRunning = false;
         return 0;
     });
     d_worker.join();
 }
コード例 #17
0
ファイル: rnd_generator.cpp プロジェクト: revitmt/misc
void rng_finilize()
{
    rng_producer_done = true;
    rng_producer_thread.join();

    /* Cleanup */
    curandDestroyGenerator(gen);
    cudaFree(devData);
}
コード例 #18
0
ファイル: UIUGens.cpp プロジェクト: 8c6794b6/supercollider
C_LINKAGE SC_API_EXPORT void unload(InterfaceTable *inTable)
{
	inputThreadRunning = false;
	uiListenThread.join();

#ifndef _WIN32
	if (d)
		XCloseDisplay(d);
#endif
}
コード例 #19
0
string CriticalSection::thread_id(thread& t)
{
	string id;
	stringstream s;

	s << t.get_id();
	s >> id;

	return id;
}
コード例 #20
0
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;
}
コード例 #21
0
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;
}
コード例 #22
0
ファイル: IPC.cpp プロジェクト: YaLTeR/TASView
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();
		}
	}
}
コード例 #23
0
ファイル: simulator.hpp プロジェクト: ltf1320/hw2015
	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();
	}
コード例 #24
0
ファイル: shmem.cpp プロジェクト: shelart/shmem
		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;
		}
コード例 #25
0
ファイル: log_rotate.cpp プロジェクト: Hannah1999/Dato-Core
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());
}
コード例 #26
0
ファイル: SipTransport.cpp プロジェクト: SilentCircle/libzina
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__, " <--");
}
コード例 #27
0
ファイル: thread_test.cpp プロジェクト: fpstovall/nrtb_beta
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();
};
コード例 #28
0
ファイル: log_rotate.cpp プロジェクト: Hannah1999/Dato-Core
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);
}
コード例 #29
0
ファイル: pthread_tools.cpp プロジェクト: Alienfeel/graphlab
 /**
  * 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
コード例 #30
0
ファイル: util.hpp プロジェクト: straszheim/ecto
 void interrupt()
 {
   ECTO_LOG_DEBUG("interrupting %p", this);
   runner.interrupt();
   ECTO_LOG_DEBUG("interrupt    %p done", this);
 }