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

Method consume_tasks

src/bthread/timer_thread.cpp:172–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172TimerThread::Task* TimerThread::Bucket::consume_tasks() {
173 Task* head = NULL;
174 if (_task_head) { // NOTE: schedule() and consume_tasks() are sequenced
175 // by TimerThread._nearest_run_time and fenced by TimerThread._mutex.
176 // We can avoid touching the mutex and related cacheline when the
177 // bucket is actually empty.
178 BAIDU_SCOPED_LOCK(_mutex);
179 if (_task_head) {
180 head = _task_head;
181 _task_head = NULL;
182 _nearest_run_time = std::numeric_limits<int64_t>::max();
183 }
184 }
185 return head;
186}
187
188TimerThread::Bucket::ScheduleResult
189TimerThread::Bucket::schedule(void (*fn)(void*), void* arg,

Callers 1

runMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected