| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/waitable_event.h" | 5 #include "base/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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 WaitableEvent::WaitableEvent(HANDLE handle) | 22 WaitableEvent::WaitableEvent(HANDLE handle) |
| 23 : handle_(handle) { | 23 : handle_(handle) { |
| 24 CHECK(handle) << "Tried to create WaitableEvent from NULL handle"; | 24 CHECK(handle) << "Tried to create WaitableEvent from NULL handle"; |
| 25 } | 25 } |
| 26 | 26 |
| 27 WaitableEvent::~WaitableEvent() { | 27 WaitableEvent::~WaitableEvent() { |
| 28 CloseHandle(handle_); | 28 CloseHandle(handle_); |
| 29 } | 29 } |
| 30 | 30 |
| 31 HANDLE WaitableEvent::Release() { |
| 32 HANDLE rv = handle_; |
| 33 handle_ = INVALID_HANDLE_VALUE; |
| 34 return rv; |
| 35 } |
| 36 |
| 31 void WaitableEvent::Reset() { | 37 void WaitableEvent::Reset() { |
| 32 ResetEvent(handle_); | 38 ResetEvent(handle_); |
| 33 } | 39 } |
| 34 | 40 |
| 35 void WaitableEvent::Signal() { | 41 void WaitableEvent::Signal() { |
| 36 SetEvent(handle_); | 42 SetEvent(handle_); |
| 37 } | 43 } |
| 38 | 44 |
| 39 bool WaitableEvent::IsSignaled() { | 45 bool WaitableEvent::IsSignaled() { |
| 40 return TimedWait(TimeDelta::FromMilliseconds(0)); | 46 return TimedWait(TimeDelta::FromMilliseconds(0)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 INFINITE); // no timeout | 88 INFINITE); // no timeout |
| 83 if (result < WAIT_OBJECT_0 || result >= WAIT_OBJECT_0 + count) { | 89 if (result < WAIT_OBJECT_0 || result >= WAIT_OBJECT_0 + count) { |
| 84 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); | 90 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); |
| 85 return 0; | 91 return 0; |
| 86 } | 92 } |
| 87 | 93 |
| 88 return result - WAIT_OBJECT_0; | 94 return result - WAIT_OBJECT_0; |
| 89 } | 95 } |
| 90 | 96 |
| 91 } // namespace base | 97 } // namespace base |
| OLD | NEW |