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

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

Issue 8221021: Modify WaitableEvent::Wait() to return void (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comment and style Created 9 years, 2 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 28 matching lines...) Expand all
39 } 39 }
40 40
41 void WaitableEvent::Signal() { 41 void WaitableEvent::Signal() {
42 SetEvent(handle_); 42 SetEvent(handle_);
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 void 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_EQ(WAIT_OBJECT_0, result) << "WaitForSingleObject failed"; 53 DCHECK_EQ(WAIT_OBJECT_0, result) << "WaitForSingleObject failed";
54 return result == WAIT_OBJECT_0;
55 } 54 }
56 55
57 bool WaitableEvent::TimedWait(const TimeDelta& max_time) { 56 bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
58 DCHECK(max_time >= TimeDelta::FromMicroseconds(0)); 57 DCHECK(max_time >= TimeDelta::FromMicroseconds(0));
59 // Be careful here. TimeDelta has a precision of microseconds, but this API 58 // 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? 59 // 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. 60 // It should be 6 to avoid returning too early.
62 double timeout = ceil(max_time.InMillisecondsF()); 61 double timeout = ceil(max_time.InMillisecondsF());
63 DWORD result = WaitForSingleObject(handle_, static_cast<DWORD>(timeout)); 62 DWORD result = WaitForSingleObject(handle_, static_cast<DWORD>(timeout));
64 switch (result) { 63 switch (result) {
(...skipping 25 matching lines...) Expand all
90 INFINITE); // no timeout 89 INFINITE); // no timeout
91 if (result >= WAIT_OBJECT_0 + count) { 90 if (result >= WAIT_OBJECT_0 + count) {
92 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); 91 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError();
93 return 0; 92 return 0;
94 } 93 }
95 94
96 return result - WAIT_OBJECT_0; 95 return result - WAIT_OBJECT_0;
97 } 96 }
98 97
99 } // namespace base 98 } // namespace base
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_unittest.cc ('k') | base/threading/worker_pool_posix_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698