diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/wtf/threading_win.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/wtf/threading_win.cc | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/chromium/third_party/blink/renderer/platform/wtf/threading_win.cc b/chromium/third_party/blink/renderer/platform/wtf/threading_win.cc index 76bef7f83ef..09cc847bd63 100644 --- a/chromium/third_party/blink/renderer/platform/wtf/threading_win.cc +++ b/chromium/third_party/blink/renderer/platform/wtf/threading_win.cc @@ -255,14 +255,22 @@ void ThreadCondition::Wait(Mutex& mutex) { } bool ThreadCondition::TimedWait(Mutex& mutex, double absolute_time) { - DWORD interval = AbsoluteTimeToWaitTimeoutInterval(absolute_time); + double current_time = WTF::CurrentTime(); - if (!interval) { + // Time is in the past - return immediately. + if (absolute_time <= current_time) { // Consider the wait to have timed out, even if our condition has already // been signaled, to match the pthreads implementation. return false; } + // If time is too far in the future (and would overflow unsigned long), wait + // forever. + DWORD interval = + (absolute_time - current_time > static_cast<double>(INT_MAX) / 1000.0) + ? INFINITE + : ((absolute_time - current_time) * 1000.0); + PlatformMutex& platform_mutex = mutex.Impl(); BOOL result = SleepConditionVariableCS( &condition_, &platform_mutex.internal_mutex_, interval); @@ -279,21 +287,6 @@ void ThreadCondition::Broadcast() { WakeAllConditionVariable(&condition_); } -DWORD AbsoluteTimeToWaitTimeoutInterval(double absolute_time) { - double current_time = WTF::CurrentTime(); - - // Time is in the past - return immediately. - if (absolute_time < current_time) - return 0; - - // Time is too far in the future (and would overflow unsigned long) - wait - // forever. - if (absolute_time - current_time > static_cast<double>(INT_MAX) / 1000.0) - return INFINITE; - - return static_cast<DWORD>((absolute_time - current_time) * 1000.0); -} - #if DCHECK_IS_ON() static bool g_thread_created = false; |