OLD | NEW |
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 <windows.h> | 7 #include <windows.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <utility> |
| 11 |
10 #include "base/logging.h" | 12 #include "base/logging.h" |
11 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
12 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
13 #include "base/time/time.h" | 15 #include "base/time/time.h" |
14 | 16 |
15 namespace base { | 17 namespace base { |
16 | 18 |
17 WaitableEvent::WaitableEvent(bool manual_reset, bool signaled) | 19 WaitableEvent::WaitableEvent(bool manual_reset, bool signaled) |
18 : handle_(CreateEvent(NULL, manual_reset, signaled, NULL)) { | 20 : handle_(CreateEvent(NULL, manual_reset, signaled, NULL)) { |
19 // We're probably going to crash anyways if this is ever NULL, so we might as | 21 // We're probably going to crash anyways if this is ever NULL, so we might as |
20 // well make our stack reports more informative by crashing here. | 22 // well make our stack reports more informative by crashing here. |
21 CHECK(handle_.IsValid()); | 23 CHECK(handle_.IsValid()); |
22 } | 24 } |
23 | 25 |
24 WaitableEvent::WaitableEvent(win::ScopedHandle handle) | 26 WaitableEvent::WaitableEvent(win::ScopedHandle handle) |
25 : handle_(handle.Pass()) { | 27 : handle_(std::move(handle)) { |
26 CHECK(handle_.IsValid()) << "Tried to create WaitableEvent from NULL handle"; | 28 CHECK(handle_.IsValid()) << "Tried to create WaitableEvent from NULL handle"; |
27 } | 29 } |
28 | 30 |
29 WaitableEvent::~WaitableEvent() { | 31 WaitableEvent::~WaitableEvent() { |
30 } | 32 } |
31 | 33 |
32 void WaitableEvent::Reset() { | 34 void WaitableEvent::Reset() { |
33 ResetEvent(handle_.Get()); | 35 ResetEvent(handle_.Get()); |
34 } | 36 } |
35 | 37 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 INFINITE); // no timeout | 90 INFINITE); // no timeout |
89 if (result >= WAIT_OBJECT_0 + count) { | 91 if (result >= WAIT_OBJECT_0 + count) { |
90 DPLOG(FATAL) << "WaitForMultipleObjects failed"; | 92 DPLOG(FATAL) << "WaitForMultipleObjects failed"; |
91 return 0; | 93 return 0; |
92 } | 94 } |
93 | 95 |
94 return result - WAIT_OBJECT_0; | 96 return result - WAIT_OBJECT_0; |
95 } | 97 } |
96 | 98 |
97 } // namespace base | 99 } // namespace base |
OLD | NEW |