Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: base/synchronization/waitable_event_win.cc

Issue 1040833002: Base: Truncate the timeout of WaitableEvent::TimedWait on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/synchronization/waitable_event_win.cc
diff --git a/base/synchronization/waitable_event_win.cc b/base/synchronization/waitable_event_win.cc
index 6bec4b423360fd258f52d5fec56ce9ef7fe067c5..4db56277b7cdbaff42582dac2212fd50b79c01e0 100644
--- a/base/synchronization/waitable_event_win.cc
+++ b/base/synchronization/waitable_event_win.cc
@@ -51,10 +51,10 @@ void WaitableEvent::Wait() {
bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
base::ThreadRestrictions::AssertWaitAllowed();
DCHECK_GE(max_time, TimeDelta());
- // 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.
- DWORD timeout = saturated_cast<DWORD>(max_time.InMillisecondsRoundedUp());
+ // Truncate the timeout to milliseconds. The API specifies that this method
+ // can return in less than |max_time| (when returning false), as the argument
+ // is the maximum time that a caller is willing to wait.
+ DWORD timeout = saturated_cast<DWORD>(max_time.InMilliseconds());
DWORD result = WaitForSingleObject(handle_.Get(), timeout);
switch (result) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698