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

Function interrupt_and_consume_waiters

src/bthread/task_group.cpp:1046–1062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044bool erase_from_butex_because_of_interruption(ButexWaiter* bw);
1045
1046static int interrupt_and_consume_waiters(
1047 bthread_t tid, ButexWaiter** pw, uint64_t* sleep_id) {
1048 TaskMeta* const m = TaskGroup::address_meta(tid);
1049 if (m == NULL) {
1050 return EINVAL;
1051 }
1052 const uint32_t given_ver = get_version(tid);
1053 BAIDU_SCOPED_LOCK(m->version_lock);
1054 if (given_ver == *m->version_butex) {
1055 *pw = m->current_waiter.exchange(NULL, butil::memory_order_acquire);
1056 *sleep_id = m->current_sleep;
1057 m->current_sleep = 0; // only one stopper gets the sleep_id
1058 m->interrupted = true;
1059 return 0;
1060 }
1061 return EINVAL;
1062}
1063
1064static int set_butex_waiter(bthread_t tid, ButexWaiter* w) {
1065 TaskMeta* const m = TaskGroup::address_meta(tid);

Callers 1

interruptMethod · 0.85

Calls 2

get_versionFunction · 0.70
exchangeMethod · 0.45

Tested by

no test coverage detected