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

Method signal

src/bthread/countdown_event.cpp:41–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41void CountdownEvent::signal(int sig, bool flush) {
42 // Have to save _butex, *this is probably defreferenced by the wait thread
43 // which sees fetch_sub
44 void* const saved_butex = _butex;
45 const int prev = ((butil::atomic<int>*)_butex)
46 ->fetch_sub(sig, butil::memory_order_release);
47 // DON'T touch *this ever after
48 if (prev > sig) {
49 return;
50 }
51 LOG_IF(ERROR, prev < sig) << "Counter is over decreased";
52 butex_wake_all(saved_butex, flush);
53}
54
55int CountdownEvent::wait() {
56 _wait_was_invoked = true;

Callers 15

RunMethod · 0.80
signalerFunction · 0.80
TESTFunction · 0.80
butex_wake_all_func1Function · 0.80
butex_wake_all_func2Function · 0.80
TESTFunction · 0.80
butex_requeue_func1Function · 0.80
butex_requeue_func2Function · 0.80
RunMethod · 0.80
addFunction · 0.80
add_with_suspendFunction · 0.80
check_orderFunction · 0.80

Calls 2

butex_wake_allFunction · 0.85
fetch_subMethod · 0.80

Tested by 14

signalerFunction · 0.64
TESTFunction · 0.64
butex_wake_all_func1Function · 0.64
butex_wake_all_func2Function · 0.64
TESTFunction · 0.64
butex_requeue_func1Function · 0.64
butex_requeue_func2Function · 0.64
RunMethod · 0.64
addFunction · 0.64
add_with_suspendFunction · 0.64
check_orderFunction · 0.64
add_with_suspend2Function · 0.64