summaryrefslogtreecommitdiffstats
path: root/base/waitable_event_win.cc
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 06:30:58 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 06:30:58 +0000
commitb24250fc9857d219ad617e2a14e145b65724cb61 (patch)
tree858c55a80b23d0e8e62d1f9d4c4b724c6c924860 /base/waitable_event_win.cc
parent099cec761ad00232f5ce8483a163356b06065980 (diff)
downloadchromium_src-b24250fc9857d219ad617e2a14e145b65724cb61.zip
chromium_src-b24250fc9857d219ad617e2a14e145b65724cb61.tar.gz
chromium_src-b24250fc9857d219ad617e2a14e145b65724cb61.tar.bz2
reland r1075 w/ tweak to fix test failures
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/waitable_event_win.cc')
-rw-r--r--base/waitable_event_win.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/base/waitable_event_win.cc b/base/waitable_event_win.cc
index da2d2d8..e23eea0 100644
--- a/base/waitable_event_win.cc
+++ b/base/waitable_event_win.cc
@@ -29,6 +29,7 @@
#include "base/waitable_event.h"
+#include <math.h>
#include <windows.h>
#include "base/logging.h"
@@ -68,8 +69,12 @@ bool WaitableEvent::Wait() {
}
bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
- int32 timeout = static_cast<int32>(max_time.InMilliseconds());
- DWORD result = WaitForSingleObject(event_, timeout);
+ DCHECK(max_time >= TimeDelta::FromMicroseconds(0));
+ // Be careful here. TimeDelta has a precision of microseconds, but this API
+ // is in milliseconds. If there are 5.5ms left, should the delay be 5 or 6?
+ // It should be 6 to avoid returning too early.
+ double timeout = ceil(max_time.InMillisecondsF());
+ DWORD result = WaitForSingleObject(event_, static_cast<DWORD>(timeout));
switch (result) {
case WAIT_OBJECT_0:
return true;