Index: base/atomic_ref_count.h |
=================================================================== |
--- base/atomic_ref_count.h (revision 111700) |
+++ base/atomic_ref_count.h (working copy) |
@@ -51,6 +51,24 @@ |
return base::AtomicRefCountDecN(ptr, 1); |
} |
+// Increment a reference count by 1 and return the new value. |
+inline AtomicRefCount AtomicRefCountIncAndReturnValue( |
+ volatile AtomicRefCount *ptr) { |
+ ANNOTATE_HAPPENS_BEFORE(ptr); |
+ AtomicRefCount res = subtle::Barrier_AtomicIncrement(ptr, 1); |
+ ANNOTATE_HAPPENS_AFTER(ptr); |
+ return res; |
+} |
+ |
+// Decrement a reference count by 1 and return the new value. |
+inline AtomicRefCount AtomicRefCountDecAndReturnValue( |
+ volatile AtomicRefCount *ptr) { |
+ ANNOTATE_HAPPENS_BEFORE(ptr); |
+ AtomicRefCount res = subtle::Barrier_AtomicIncrement(ptr, -1); |
+ ANNOTATE_HAPPENS_AFTER(ptr); |
+ return res; |
+} |
+ |
// Return whether the reference count is one. If the reference count is used |
// in the conventional way, a refrerence count of 1 implies that the current |
// thread owns the reference and no other thread shares it. This call performs |