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 #ifndef BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 5 #ifndef BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
6 #define BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 6 #define BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 | 10 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 virtual ~WaitableEventKernel(); | 148 virtual ~WaitableEventKernel(); |
149 | 149 |
150 bool Dequeue(Waiter* waiter, void* tag); | 150 bool Dequeue(Waiter* waiter, void* tag); |
151 | 151 |
152 Lock lock_; | 152 Lock lock_; |
153 const bool manual_reset_; | 153 const bool manual_reset_; |
154 bool signaled_; | 154 bool signaled_; |
155 std::list<Waiter*> waiters_; | 155 std::list<Waiter*> waiters_; |
156 }; | 156 }; |
157 | 157 |
158 scoped_refptr<WaitableEventKernel> kernel_; | 158 typedef std::pair<WaitableEvent*, size_t> WaiterAndIndex; |
159 | |
160 bool SignalAll(); | |
161 bool SignalOne(); | |
162 void Enqueue(Waiter* waiter); | |
163 | 159 |
164 // When dealing with arrays of WaitableEvent*, we want to sort by the address | 160 // When dealing with arrays of WaitableEvent*, we want to sort by the address |
165 // of the WaitableEvent in order to have a globally consistent locking order. | 161 // of the WaitableEvent in order to have a globally consistent locking order. |
166 // In that case we keep them, in sorted order, in an array of pairs where the | 162 // In that case we keep them, in sorted order, in an array of pairs where the |
167 // second element is the index of the WaitableEvent in the original, | 163 // second element is the index of the WaitableEvent in the original, |
168 // unsorted, array. | 164 // unsorted, array. |
169 typedef std::pair<WaitableEvent*, size_t> WaiterAndIndex; | |
170 static size_t EnqueueMany(WaiterAndIndex* waitables, | 165 static size_t EnqueueMany(WaiterAndIndex* waitables, |
171 size_t count, Waiter* waiter); | 166 size_t count, Waiter* waiter); |
| 167 |
| 168 bool SignalAll(); |
| 169 bool SignalOne(); |
| 170 void Enqueue(Waiter* waiter); |
| 171 |
| 172 scoped_refptr<WaitableEventKernel> kernel_; |
172 #endif | 173 #endif |
173 | 174 |
174 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); | 175 DISALLOW_COPY_AND_ASSIGN(WaitableEvent); |
175 }; | 176 }; |
176 | 177 |
177 } // namespace base | 178 } // namespace base |
178 | 179 |
179 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ | 180 #endif // BASE_SYNCHRONIZATION_WAITABLE_EVENT_H_ |
OLD | NEW |