| 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 "base/condition_variable.h" | 7 #include "base/condition_variable.h" |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 | 10 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 if (sw.fired()) | 264 if (sw.fired()) |
| 265 break; | 265 break; |
| 266 | 266 |
| 267 cv.Wait(); | 267 cv.Wait(); |
| 268 } | 268 } |
| 269 lock.Release(); | 269 lock.Release(); |
| 270 | 270 |
| 271 // The address of the WaitableEvent which fired is stored in the SyncWaiter. | 271 // The address of the WaitableEvent which fired is stored in the SyncWaiter. |
| 272 WaitableEvent *const signaled_event = sw.signaled_event(); | 272 WaitableEvent *const signaled_event = sw.signaled_event(); |
| 273 // This will store the index of the raw_waitables which fired. | 273 // This will store the index of the raw_waitables which fired. |
| 274 size_t signaled_index; | 274 size_t signaled_index = 0; |
| 275 | 275 |
| 276 // Take the locks of each WaitableEvent in turn (except the signaled one) and | 276 // Take the locks of each WaitableEvent in turn (except the signaled one) and |
| 277 // remove our SyncWaiter from the wait-list | 277 // remove our SyncWaiter from the wait-list |
| 278 for (size_t i = 0; i < count; ++i) { | 278 for (size_t i = 0; i < count; ++i) { |
| 279 if (raw_waitables[i] != signaled_event) { | 279 if (raw_waitables[i] != signaled_event) { |
| 280 raw_waitables[i]->lock_.Acquire(); | 280 raw_waitables[i]->lock_.Acquire(); |
| 281 // There's no possible ABA issue with the address of the SyncWaiter here | 281 // There's no possible ABA issue with the address of the SyncWaiter here |
| 282 // because it lives on the stack. Thus the tag value is just the pointer | 282 // because it lives on the stack. Thus the tag value is just the pointer |
| 283 // value again. | 283 // value again. |
| 284 raw_waitables[i]->Dequeue(&sw, &sw); | 284 raw_waitables[i]->Dequeue(&sw, &sw); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return true; | 383 return true; |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 return false; | 387 return false; |
| 388 } | 388 } |
| 389 | 389 |
| 390 // ----------------------------------------------------------------------------- | 390 // ----------------------------------------------------------------------------- |
| 391 | 391 |
| 392 } // namespace base | 392 } // namespace base |
| OLD | NEW |