Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: base/atomic_ref_count.h

Issue 2349393002: Use platform sized counters for the refcounted classes in base. (Closed)
Patch Set: fix implicit cast in seqlock test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/memory/ref_counted.h » ('j') | base/memory/ref_counted.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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/memory/ref_counted.h directly instead. 6 // counting. Please use base/memory/ref_counted.h directly instead.
7 7
8 #ifndef BASE_ATOMIC_REF_COUNT_H_ 8 #ifndef BASE_ATOMIC_REF_COUNT_H_
9 #define BASE_ATOMIC_REF_COUNT_H_ 9 #define BASE_ATOMIC_REF_COUNT_H_
10 10
11 #include "base/atomicops.h" 11 #include "base/atomicops.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 typedef subtle::Atomic32 AtomicRefCount; 15 typedef subtle::AtomicWord AtomicRefCount;
16 16
17 // Increment a reference count by "increment", which must exceed 0. 17 // Increment a reference count by "increment", which must exceed 0.
18 inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, 18 inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr,
19 AtomicRefCount increment) { 19 AtomicRefCount increment) {
20 subtle::NoBarrier_AtomicIncrement(ptr, increment); 20 subtle::NoBarrier_AtomicIncrement(ptr, increment);
21 } 21 }
22 22
23 // Decrement a reference count by "decrement", which must exceed 0, 23 // Decrement a reference count by "decrement", which must exceed 0,
24 // and return whether the result is non-zero. 24 // and return whether the result is non-zero.
25 // Insert barriers to ensure that state written before the reference count 25 // Insert barriers to ensure that state written before the reference count
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // referencing counting, the object will be destroyed, so the reference count 57 // referencing counting, the object will be destroyed, so the reference count
58 // should never be zero. Hence this is generally used for a debug check. 58 // should never be zero. Hence this is generally used for a debug check.
59 inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) { 59 inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) {
60 bool res = (subtle::Acquire_Load(ptr) == 0); 60 bool res = (subtle::Acquire_Load(ptr) == 0);
61 return res; 61 return res;
62 } 62 }
63 63
64 } // namespace base 64 } // namespace base
65 65
66 #endif // BASE_ATOMIC_REF_COUNT_H_ 66 #endif // BASE_ATOMIC_REF_COUNT_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/ref_counted.h » ('j') | base/memory/ref_counted.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698