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 // This is a low level implementation of atomic semantics for reference | 5 // This is a low level implementation of atomic semantics for reference |
6 // counting. Please use base/ref_counted.h directly instead. | 6 // counting. Please use base/ref_counted.h directly instead. |
7 // | 7 // |
8 // The implementation includes annotations to avoid some false positives | 8 // The implementation includes annotations to avoid some false positives |
9 // when using data race detection tools. | 9 // when using data race detection tools. |
10 | 10 |
11 #ifndef BASE_ATOMIC_REF_COUNT_H_ | 11 #ifndef BASE_ATOMIC_REF_COUNT_H_ |
12 #define BASE_ATOMIC_REF_COUNT_H_ | 12 #define BASE_ATOMIC_REF_COUNT_H_ |
13 | 13 |
14 #include "base/atomicops.h" | 14 #include "base/atomicops.h" |
15 #include "base/dynamic_annotations.h" | 15 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 | 18 |
19 typedef subtle::Atomic32 AtomicRefCount; | 19 typedef subtle::Atomic32 AtomicRefCount; |
20 | 20 |
21 // Increment a reference count by "increment", which must exceed 0. | 21 // Increment a reference count by "increment", which must exceed 0. |
22 inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, | 22 inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, |
23 AtomicRefCount increment) { | 23 AtomicRefCount increment) { |
24 subtle::NoBarrier_AtomicIncrement(ptr, increment); | 24 subtle::NoBarrier_AtomicIncrement(ptr, increment); |
25 } | 25 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 bool res = (subtle::Acquire_Load(ptr) == 0); | 71 bool res = (subtle::Acquire_Load(ptr) == 0); |
72 if (res) { | 72 if (res) { |
73 ANNOTATE_HAPPENS_AFTER(ptr); | 73 ANNOTATE_HAPPENS_AFTER(ptr); |
74 } | 74 } |
75 return res; | 75 return res; |
76 } | 76 } |
77 | 77 |
78 } // namespace base | 78 } // namespace base |
79 | 79 |
80 #endif // BASE_ATOMIC_REF_COUNT_H_ | 80 #endif // BASE_ATOMIC_REF_COUNT_H_ |
OLD | NEW |