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

Side by Side Diff: base/synchronization/waitable_event_win.cc

Issue 6469070: More DCHECK() updates. A mixture of _EQ and _GE. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updating pickle.h order Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/synchronization/waitable_event.h" 5 #include "base/synchronization/waitable_event.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 bool WaitableEvent::IsSignaled() { 45 bool WaitableEvent::IsSignaled() {
46 return TimedWait(TimeDelta::FromMilliseconds(0)); 46 return TimedWait(TimeDelta::FromMilliseconds(0));
47 } 47 }
48 48
49 bool WaitableEvent::Wait() { 49 bool WaitableEvent::Wait() {
50 DWORD result = WaitForSingleObject(handle_, INFINITE); 50 DWORD result = WaitForSingleObject(handle_, INFINITE);
51 // It is most unexpected that this should ever fail. Help consumers learn 51 // It is most unexpected that this should ever fail. Help consumers learn
52 // about it if it should ever fail. 52 // about it if it should ever fail.
53 DCHECK(result == WAIT_OBJECT_0) << "WaitForSingleObject failed"; 53 DCHECK_EQ(WAIT_OBJECT_0, result) << "WaitForSingleObject failed";
54 return result == WAIT_OBJECT_0; 54 return result == WAIT_OBJECT_0;
55 } 55 }
56 56
57 bool WaitableEvent::TimedWait(const TimeDelta& max_time) { 57 bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
58 DCHECK(max_time >= TimeDelta::FromMicroseconds(0)); 58 DCHECK(max_time >= TimeDelta::FromMicroseconds(0));
59 // Be careful here. TimeDelta has a precision of microseconds, but this API 59 // Be careful here. TimeDelta has a precision of microseconds, but this API
60 // is in milliseconds. If there are 5.5ms left, should the delay be 5 or 6? 60 // is in milliseconds. If there are 5.5ms left, should the delay be 5 or 6?
61 // It should be 6 to avoid returning too early. 61 // It should be 6 to avoid returning too early.
62 double timeout = ceil(max_time.InMillisecondsF()); 62 double timeout = ceil(max_time.InMillisecondsF());
63 DWORD result = WaitForSingleObject(handle_, static_cast<DWORD>(timeout)); 63 DWORD result = WaitForSingleObject(handle_, static_cast<DWORD>(timeout));
(...skipping 26 matching lines...) Expand all
90 INFINITE); // no timeout 90 INFINITE); // no timeout
91 if (result >= WAIT_OBJECT_0 + count) { 91 if (result >= WAIT_OBJECT_0 + count) {
92 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); 92 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError();
93 return 0; 93 return 0;
94 } 94 }
95 95
96 return result - WAIT_OBJECT_0; 96 return result - WAIT_OBJECT_0;
97 } 97 }
98 98
99 } // namespace base 99 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/condition_variable_posix.cc ('k') | base/threading/thread_local_storage_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698