summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-05-19 18:03:31 -0700
committerMathias Agopian <mathias@google.com>2011-05-23 16:13:48 -0700
commit3d6881f3940dd19268006e71dd2ed9896588dfb6 (patch)
tree7cd587807e26896f4cbc34e5aa47319c0c5df55f /include
parent34cd9b72f1474ccbfd2338049d81a24bfa814f35 (diff)
downloadframeworks_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.h9
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,