summaryrefslogtreecommitdiffstats
path: root/base/ref_counted.h
diff options
context:
space:
mode:
authordeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-06 11:55:42 +0000
committerdeanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-06 11:55:42 +0000
commitf9be5380bdd0e731b4e4127990b09781fb9a36e8 (patch)
treefa6e15cbba6bf90dfa3745770b998401b142bb0f /base/ref_counted.h
parent156f807989a09824aaf37b194376445b19f5b3f5 (diff)
downloadchromium_src-f9be5380bdd0e731b4e4127990b09781fb9a36e8.zip
chromium_src-f9be5380bdd0e731b4e4127990b09781fb9a36e8.tar.gz
chromium_src-f9be5380bdd0e731b4e4127990b09781fb9a36e8.tar.bz2
Move ref_counted to the new atomic_ref_count interface.
BUG=1112286 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/ref_counted.h')
-rw-r--r--base/ref_counted.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/base/ref_counted.h b/base/ref_counted.h
index 36f4ab4..e9b5fe1 100644
--- a/base/ref_counted.h
+++ b/base/ref_counted.h
@@ -30,7 +30,7 @@
#ifndef BASE_REF_COUNTED_H__
#define BASE_REF_COUNTED_H__
-#include "base/atomic.h"
+#include "base/atomic_ref_count.h"
#include "base/basictypes.h"
#include "base/logging.h"
@@ -115,18 +115,15 @@ class RefCountedThreadSafe {
#ifndef NDEBUG
DCHECK(!in_dtor_);
#endif
- AtomicIncrement(&ref_count_);
+ AtomicRefCountInc(&ref_count_);
}
void Release() {
#ifndef NDEBUG
DCHECK(!in_dtor_);
+ DCHECK(!AtomicRefCountIsZero(&ref_count_));
#endif
- // We need to insert memory barriers to ensure that state written before
- // the reference count became 0 will be visible to a thread that has just
- // made the count 0.
- // TODO(wtc): Bug 1112286: use the barrier variant of AtomicDecrement.
- if (AtomicDecrement(&ref_count_) == 0) {
+ if (!AtomicRefCountDec(&ref_count_)) {
#ifndef NDEBUG
in_dtor_ = true;
#endif
@@ -135,7 +132,7 @@ class RefCountedThreadSafe {
}
private:
- int32 ref_count_;
+ AtomicRefCount ref_count_;
#ifndef NDEBUG
bool in_dtor_;
#endif