| 70 | } |
| 71 | |
| 72 | int 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 | |
| 86 | int bthread_cond_wait(bthread_cond_t* __restrict c, |
| 87 | bthread_mutex_t* __restrict m) { |
no test coverage detected