diff options
Diffstat (limited to 'boost/asio/detail/win_event.hpp')
-rw-r--r-- | boost/asio/detail/win_event.hpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/boost/asio/detail/win_event.hpp b/boost/asio/detail/win_event.hpp index 7a7d54fac6..4c00068010 100644 --- a/boost/asio/detail/win_event.hpp +++ b/boost/asio/detail/win_event.hpp @@ -112,6 +112,27 @@ public: } } + // Timed wait for the event to become signalled. + template <typename Lock> + bool wait_for_usec(Lock& lock, long usec) + { + BOOST_ASIO_ASSERT(lock.locked()); + if ((state_ & 1) == 0) + { + state_ += 2; + lock.unlock(); + DWORD msec = usec > 0 ? (usec < 1000 ? 1 : usec / 1000) : 0; +#if defined(BOOST_ASIO_WINDOWS_APP) + ::WaitForMultipleObjectsEx(2, events_, false, msec, false); +#else // defined(BOOST_ASIO_WINDOWS_APP) + ::WaitForMultipleObjects(2, events_, false, msec); +#endif // defined(BOOST_ASIO_WINDOWS_APP) + lock.lock(); + state_ -= 2; + } + return (state_ & 1) != 0; + } + private: HANDLE events_[2]; std::size_t state_; |