| 46 | } |
| 47 | |
| 48 | inline void Wait() { |
| 49 | unsigned int v = state_.fetch_or(1, std::memory_order_acq_rel); |
| 50 | if ((v >> 1) == 0) return; |
| 51 | mutex_lock l(mu_); |
| 52 | while (!notified_) { |
| 53 | cond_var_.wait(l); |
| 54 | } |
| 55 | } |
| 56 | // Wait for the specified time, return false iff the count has not dropped to |
| 57 | // zero before the timeout expired. |
| 58 | inline bool WaitFor(std::chrono::milliseconds ms) { |