MCPcopy Create free account
hub / github.com/apache/brpc / stop_and_join

Method stop_and_join

src/bthread/timer_thread.cpp:447–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447void TimerThread::stop_and_join() {
448 _stop.store(true, butil::memory_order_relaxed);
449 if (_started) {
450 {
451 BAIDU_SCOPED_LOCK(_mutex);
452 // trigger pull_again and wakeup TimerThread
453 _nearest_run_time = 0;
454 ++_nsignals;
455 }
456 if (pthread_self() != _thread) {
457 // stop_and_join was not called from a running task.
458 // wake up the timer thread in case it is sleeping.
459 futex_wake_private(&_nsignals, 1);
460 pthread_join(_thread, NULL);
461 }
462 }
463}
464
465static pthread_once_t g_timer_thread_once = PTHREAD_ONCE_INIT;
466static TimerThread* g_timer_thread = NULL;

Callers 4

~ControlServiceImplMethod · 0.45
TESTFunction · 0.45
bthread_stop_worldFunction · 0.45

Calls 2

futex_wake_privateFunction · 0.70
storeMethod · 0.45

Tested by 1

TESTFunction · 0.36