| 35 | } |
| 36 | |
| 37 | void TCountDownLatch::Wait() const |
| 38 | { |
| 39 | while (true) { |
| 40 | #ifndef _linux_ |
| 41 | TGuard<TMutex> guard(Mutex_); |
| 42 | #endif |
| 43 | auto count = Count_.load(std::memory_order::acquire); |
| 44 | if (count == 0) { |
| 45 | return; |
| 46 | } |
| 47 | #ifdef _linux_ |
| 48 | int rv = NThreading::FutexWait( |
| 49 | const_cast<int*>(reinterpret_cast<const int*>(&Count_)), |
| 50 | count); |
| 51 | YT_VERIFY(rv >= 0 || errno == EWOULDBLOCK || errno == EINTR); |
| 52 | #else |
| 53 | ConditionVariable_.WaitI(Mutex_); |
| 54 | #endif |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | bool TCountDownLatch::TryWait() const |
| 59 | { |