| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // static | 76 // static |
| 77 size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { | 77 size_t WaitableEvent::WaitMany(WaitableEvent** events, size_t count) { |
| 78 HANDLE handles[MAXIMUM_WAIT_OBJECTS]; | 78 HANDLE handles[MAXIMUM_WAIT_OBJECTS]; |
| 79 CHECK(count <= MAXIMUM_WAIT_OBJECTS) | 79 CHECK(count <= MAXIMUM_WAIT_OBJECTS) |
| 80 << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; | 80 << "Can only wait on " << MAXIMUM_WAIT_OBJECTS << " with WaitMany"; |
| 81 | 81 |
| 82 for (size_t i = 0; i < count; ++i) | 82 for (size_t i = 0; i < count; ++i) |
| 83 handles[i] = events[i]->handle(); | 83 handles[i] = events[i]->handle(); |
| 84 | 84 |
| 85 // The cast is safe because count is small - see the CHECK above. |
| 85 DWORD result = | 86 DWORD result = |
| 86 WaitForMultipleObjects(count, handles, | 87 WaitForMultipleObjects(static_cast<DWORD>(count), |
| 88 handles, |
| 87 FALSE, // don't wait for all the objects | 89 FALSE, // don't wait for all the objects |
| 88 INFINITE); // no timeout | 90 INFINITE); // no timeout |
| 89 if (result >= WAIT_OBJECT_0 + count) { | 91 if (result >= WAIT_OBJECT_0 + count) { |
| 90 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); | 92 NOTREACHED() << "WaitForMultipleObjects failed: " << GetLastError(); |
| 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 |