diff options
author | Mathias Agopian <mathias@google.com> | 2011-05-19 18:03:31 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-05-19 19:40:01 -0700 |
commit | 6db8c505398a0979853f6c166e0a8bcafd9268f8 (patch) | |
tree | af906178d8b458e0030034809bccc962bfdd59ac /libs | |
parent | 14a2935809e73a9d824888dc837f2f017100fd26 (diff) | |
download | frameworks_base-6db8c505398a0979853f6c166e0a8bcafd9268f8.zip frameworks_base-6db8c505398a0979853f6c166e0a8bcafd9268f8.tar.gz frameworks_base-6db8c505398a0979853f6c166e0a8bcafd9268f8.tar.bz2 |
RefBase subclasses can now decide how they want to be destroyed.
This adds a destroy() virtual on RefBase which
sublasses can implement. destroy() is called
in lieu of the destructor whenthe last strong
ref goes away.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/RefBase.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp index 2034486..9f55a71 100644 --- a/libs/utils/RefBase.cpp +++ b/libs/utils/RefBase.cpp @@ -345,6 +345,10 @@ void RefBase::incStrong(const void* id) const const_cast<RefBase*>(this)->onFirstRef(); } +void RefBase::destroy() const { + delete this; +} + void RefBase::decStrong(const void* id) const { weakref_impl* const refs = mRefs; @@ -357,7 +361,7 @@ void RefBase::decStrong(const void* id) const if (c == 1) { const_cast<RefBase*>(this)->onLastStrongRef(id); if ((refs->mFlags&OBJECT_LIFETIME_WEAK) != OBJECT_LIFETIME_WEAK) { - delete this; + destroy(); } } refs->decWeak(id); |