OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef THREAD_COLLISION_WARNER_H_ | 5 #ifndef THREAD_COLLISION_WARNER_H_ |
6 #define THREAD_COLLISION_WARNER_H_ | 6 #define THREAD_COLLISION_WARNER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 // Same as EnterSelf but recursion is not allowed. | 219 // Same as EnterSelf but recursion is not allowed. |
220 void Enter(); | 220 void Enter(); |
221 | 221 |
222 // Removes the thread_id stored in order to allow other threads to | 222 // Removes the thread_id stored in order to allow other threads to |
223 // call EnterSelf or Enter. | 223 // call EnterSelf or Enter. |
224 void Leave(); | 224 void Leave(); |
225 | 225 |
226 // This stores the thread id that is inside the critical section, if the | 226 // This stores the thread id that is inside the critical section, if the |
227 // value is 0 then no thread is inside. | 227 // value is 0 then no thread is inside. |
228 volatile int valid_thread_id_; | 228 volatile subtle::Atomic32 valid_thread_id_; |
229 | 229 |
230 // Counter to trace how many time a critical section was "pinned" | 230 // Counter to trace how many time a critical section was "pinned" |
231 // (when allowed) in order to unpin it when counter_ reaches 0. | 231 // (when allowed) in order to unpin it when counter_ reaches 0. |
232 volatile subtle::Atomic32 counter_; | 232 volatile subtle::Atomic32 counter_; |
233 | 233 |
234 // Here only for class unit tests purpose, during the test I need to not | 234 // Here only for class unit tests purpose, during the test I need to not |
235 // DCHECK but notify the collision with something else. | 235 // DCHECK but notify the collision with something else. |
236 AsserterBase* asserter_; | 236 AsserterBase* asserter_; |
237 | 237 |
238 DISALLOW_COPY_AND_ASSIGN(ThreadCollisionWarner); | 238 DISALLOW_COPY_AND_ASSIGN(ThreadCollisionWarner); |
239 }; | 239 }; |
240 | 240 |
241 } // namespace base | 241 } // namespace base |
242 | 242 |
243 #endif // THREAD_COLLISION_WARNER_H_ | 243 #endif // THREAD_COLLISION_WARNER_H_ |
OLD | NEW |