| 59 | } |
| 60 | |
| 61 | int bthread_cond_signal(bthread_cond_t* c) { |
| 62 | bthread::CondInternal* ic = reinterpret_cast<bthread::CondInternal*>(c); |
| 63 | // ic is probably dereferenced after fetch_add, save required fields before |
| 64 | // this point |
| 65 | butil::atomic<int>* const saved_seq = ic->seq; |
| 66 | saved_seq->fetch_add(1, butil::memory_order_release); |
| 67 | // don't touch ic any more |
| 68 | bthread::butex_wake(saved_seq); |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | int bthread_cond_broadcast(bthread_cond_t* c) { |
| 73 | bthread::CondInternal* ic = reinterpret_cast<bthread::CondInternal*>(c); |