| 34 | } |
| 35 | |
| 36 | bool ResetEvent::internalWait(ClockConfig::Duration timeDuration) |
| 37 | { |
| 38 | std::unique_lock< decltype(m_mutex) > lock(m_mutex); |
| 39 | |
| 40 | auto hasReceivedSignal = false; |
| 41 | |
| 42 | if (!m_signaled) |
| 43 | { |
| 44 | ++m_waitCount; |
| 45 | |
| 46 | if (timeDuration == ClockConfig::Duration()) |
| 47 | { |
| 48 | do |
| 49 | { |
| 50 | m_conditionVariable.wait(lock); |
| 51 | } |
| 52 | while (!m_signaled); |
| 53 | |
| 54 | hasReceivedSignal = true; |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | hasReceivedSignal = m_conditionVariable.wait_for(lock, timeDuration, [this] { return this->m_signaled; }); |
| 59 | } |
| 60 | |
| 61 | --m_waitCount; |
| 62 | } |
| 63 | |
| 64 | return hasReceivedSignal || m_signaled; |
| 65 | } |
| 66 | |
| 67 | bool ResetEvent::wait(ClockConfig::Duration timeDuration) |
| 68 | { |