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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // It is most unexpected that this should ever fail. Help consumers learn | 66 // It is most unexpected that this should ever fail. Help consumers learn |
67 // about it if it should ever fail. | 67 // about it if it should ever fail. |
68 NOTREACHED() << "WaitForSingleObject failed"; | 68 NOTREACHED() << "WaitForSingleObject failed"; |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 // static | 72 // static |
73 size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { | 73 size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { |
74 base::ThreadRestrictions::AssertWaitAllowed(); | 74 base::ThreadRestrictions::AssertWaitAllowed(); |
75 HANDLE handles[MAXIMUM_WAIT_OBJECTS]; | 75 HANDLE handles[MAXIMUM_WAIT_OBJECTS]; |
76 CHECK_LE(count, MAXIMUM_WAIT_OBJECTS) | 76 CHECK_LE(count, static_cast<size_t>(MAXIMUM_WAIT_OBJECTS)) |
77 << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; | 77 << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; |
78 | 78 |
79 for (size_t i = 0; i < count; ++i) | 79 for (size_t i = 0; i < count; ++i) |
80 handles[i] = events[i]->handle(); | 80 handles[i] = events[i]->handle(); |
81 | 81 |
82 // The cast is safe because count is small - see the CHECK above. | 82 // The cast is safe because count is small - see the CHECK above. |
83 DWORD result = | 83 DWORD result = |
84 WaitForMultipleObjects(static_cast<DWORD>(count), | 84 WaitForMultipleObjects(static_cast<DWORD>(count), |
85 handles, | 85 handles, |
86 FALSE, // don't wait for all the objects | 86 FALSE, // don't wait for all the objects |
87 INFINITE); // no timeout | 87 INFINITE); // no timeout |
88 if (result >= WAIT_OBJECT_0 + count) { | 88 if (result >= WAIT_OBJECT_0 + count) { |
89 DPLOG(FATAL) << "WaitForMultipleObjects failed"; | 89 DPLOG(FATAL) << "WaitForMultipleObjects failed"; |
90 return 0; | 90 return 0; |
91 } | 91 } |
92 | 92 |
93 return result - WAIT_OBJECT_0; | 93 return result - WAIT_OBJECT_0; |
94 } | 94 } |
95 | 95 |
96 } // namespace base | 96 } // namespace base |
OLD | NEW |