Bug 912299 - Make RefCounted's refcount field mutable. r=waldo

This commit is contained in:
Seth Fowler 2013-09-06 13:32:55 -07:00
parent 46d89c4cba
commit 1d6372adb1
2 changed files with 7 additions and 7 deletions

View File

@ -68,18 +68,18 @@ class RefCounted
public:
// Compatibility with nsRefPtr.
void AddRef() {
void AddRef() const {
MOZ_ASSERT(refCnt >= 0);
++refCnt;
}
void Release() {
void Release() const {
MOZ_ASSERT(refCnt > 0);
if (0 == --refCnt) {
#ifdef DEBUG
refCnt = detail::DEAD;
#endif
delete static_cast<T*>(this);
delete static_cast<const T*>(this);
}
}
@ -93,7 +93,7 @@ class RefCounted
}
private:
typename Conditional<Atomicity == AtomicRefCount, Atomic<int>, int>::Type refCnt;
mutable typename Conditional<Atomicity == AtomicRefCount, Atomic<int>, int>::Type refCnt;
};
}

View File

@ -70,7 +70,7 @@ class LibHandle;
namespace mozilla {
namespace detail {
template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release();
template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release() const;
template <> inline RefCounted<LibHandle, AtomicRefCount>::~RefCounted()
{
@ -215,7 +215,7 @@ private:
namespace mozilla {
namespace detail {
template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release() {
template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release() const {
#ifdef DEBUG
if (refCnt > 0x7fff0000)
MOZ_ASSERT(refCnt > 0x7fffdead);
@ -228,7 +228,7 @@ template <> inline void RefCounted<LibHandle, AtomicRefCount>::Release() {
#else
refCnt = 1;
#endif
delete static_cast<LibHandle*>(this);
delete static_cast<const LibHandle*>(this);
}
}
}