Index: base/threading/platform_thread_win.cc |
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc |
index cf1e0f60ea1c0e6ed3bc5b8ce3343b5793c0c900..e9752ba21394c671d1d84214e4cd65078bd940f3 100644 |
--- a/base/threading/platform_thread_win.cc |
+++ b/base/threading/platform_thread_win.cc |
@@ -135,7 +135,12 @@ void PlatformThread::YieldCurrentThread() { |
// static |
void PlatformThread::Sleep(TimeDelta duration) { |
- ::Sleep(duration.InMillisecondsRoundedUp()); |
+ // When measured with a high resolution clock, Sleep() sometimes returns much |
+ // too early. We may need to call it repeatedly to get the desired duration. |
+ TimeTicks end = TimeTicks::Now() + duration; |
+ TimeTicks now; |
+ while ((now = TimeTicks::Now()) < end) |
+ ::Sleep((end - now).InMillisecondsRoundedUp()); |
} |
// static |