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

Function bthread_cond_broadcast

src/bthread/condition_variable.cpp:72–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72int bthread_cond_broadcast(bthread_cond_t* c) {
73 bthread::CondInternal* ic = reinterpret_cast<bthread::CondInternal*>(c);
74 bthread_mutex_t* m = ic->m.load(butil::memory_order_relaxed);
75 butil::atomic<int>* const saved_seq = ic->seq;
76 if (!m) {
77 return 0;
78 }
79 void* const saved_butex = m->butex;
80 // Wakeup one thread and requeue the rest on the mutex.
81 ic->seq->fetch_add(1, butil::memory_order_release);
82 bthread::butex_requeue(saved_seq, saved_butex);
83 return 0;
84}
85
86int bthread_cond_wait(bthread_cond_t* __restrict c,
87 bthread_mutex_t* __restrict m) {

Callers 1

notify_allMethod · 0.85

Calls 3

butex_requeueFunction · 0.85
fetch_addMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected