summaryrefslogtreecommitdiffstats
path: root/base/threading
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading')
-rw-r--r--base/threading/platform_thread_win.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index cf1e0f6..e9752ba 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