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

Function init_global_timer_thread

src/bthread/timer_thread.cpp:467–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465static pthread_once_t g_timer_thread_once = PTHREAD_ONCE_INIT;
466static TimerThread* g_timer_thread = NULL;
467static void init_global_timer_thread() {
468 g_timer_thread = new (std::nothrow) TimerThread;
469 if (g_timer_thread == NULL) {
470 LOG(FATAL) << "Fail to new g_timer_thread";
471 return;
472 }
473 TimerThreadOptions options;
474 options.bvar_prefix = "bthread_timer";
475 options.num_buckets = FLAGS_brpc_timer_num_buckets;
476 const int rc = g_timer_thread->start(&options);
477 if (rc != 0) {
478 LOG(FATAL) << "Fail to start timer_thread, " << berror(rc);
479 delete g_timer_thread;
480 g_timer_thread = NULL;
481 return;
482 }
483}
484TimerThread* get_or_create_global_timer_thread() {
485 pthread_once(&g_timer_thread_once, init_global_timer_thread);
486 return g_timer_thread;

Callers

nothing calls this directly

Calls 2

berrorFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected