diff options
author | Mathias Agopian <mathias@google.com> | 2011-05-19 18:03:31 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-05-23 16:13:48 -0700 |
commit | 3d6881f3940dd19268006e71dd2ed9896588dfb6 (patch) | |
tree | 7cd587807e26896f4cbc34e5aa47319c0c5df55f /include | |
parent | 34cd9b72f1474ccbfd2338049d81a24bfa814f35 (diff) | |
download | frameworks_native-3d6881f3940dd19268006e71dd2ed9896588dfb6.zip frameworks_native-3d6881f3940dd19268006e71dd2ed9896588dfb6.tar.gz frameworks_native-3d6881f3940dd19268006e71dd2ed9896588dfb6.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.
Bug: 4483050
Change-Id: I8cbf6044a6fd3f01043a45592b5a60fa1e5fade2
Diffstat (limited to 'include')
-rw-r--r-- | include/utils/RefBase.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h index c24c0db..1b4a310 100644 --- a/include/utils/RefBase.h +++ b/include/utils/RefBase.h @@ -115,7 +115,14 @@ public: protected: RefBase(); virtual ~RefBase(); - + + // called when the last reference goes away. this is responsible for + // calling the destructor. The default implementation just does + // "delete this;". + // Make sure to never acquire a strong reference from this function. The + // same restrictions than for destructors apply. + virtual void destroy() const; + //! Flags for extendObjectLifetime() enum { OBJECT_LIFETIME_WEAK = 0x0001, |