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

Function butex_wake

src/bthread/butex.cpp:305–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305int butex_wake(void* arg, bool nosignal) {
306 Butex* b = container_of(static_cast<butil::atomic<int>*>(arg), Butex, value);
307 ButexWaiter* front = NULL;
308 {
309 BAIDU_SCOPED_LOCK(b->waiter_lock);
310 if (b->waiters.empty()) {
311 return 0;
312 }
313 front = b->waiters.head()->value();
314 front->RemoveFromList();
315 front->container.store(NULL, butil::memory_order_relaxed);
316 }
317 if (front->tid == 0) {
318 wakeup_pthread(static_cast<ButexPthreadWaiter*>(front));
319 return 1;
320 }
321 ButexBthreadWaiter* bbw = static_cast<ButexBthreadWaiter*>(front);
322 unsleep_if_necessary(bbw, get_global_timer_thread());
323 TaskGroup* g = get_task_group(bbw->control, bbw->tag);
324 if (g == tls_task_group) {
325 run_in_local_task_group(g, bbw->task_meta, nosignal);
326 } else {
327 g->ready_to_run_remote(bbw->task_meta, check_nosignal(nosignal, g->tag()));
328 }
329 return 1;
330}
331
332int butex_wake_n(void* arg, size_t n, bool nosignal) {
333 Butex* b = container_of(static_cast<butil::atomic<int>*>(arg), Butex, value);

Callers 8

TESTFunction · 0.85
butex_playerFunction · 0.85
TESTFunction · 0.85
CoroutineMethod · 0.85
OnNewDataFromTcpMethod · 0.85
bthread_mutex_unlockFunction · 0.85
bthread_id_unlockFunction · 0.85
bthread_cond_signalFunction · 0.85

Calls 13

wakeup_pthreadFunction · 0.85
unsleep_if_necessaryFunction · 0.85
get_global_timer_threadFunction · 0.85
get_task_groupFunction · 0.85
run_in_local_task_groupFunction · 0.85
check_nosignalFunction · 0.85
headMethod · 0.80
RemoveFromListMethod · 0.80
ready_to_run_remoteMethod · 0.80
tagMethod · 0.80
emptyMethod · 0.45
valueMethod · 0.45

Tested by 3

TESTFunction · 0.68
butex_playerFunction · 0.68
TESTFunction · 0.68