summaryrefslogtreecommitdiff
path: root/src/base-object.h
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2014-08-23 00:33:04 +0200
committerTrevor Norris <trev.norris@gmail.com>2014-09-05 09:34:27 -0700
commit8e6706ea95c81534357c84237f561a0a8073c38e (patch)
tree59db94d6b0d986bb91506ae524855af562fd2173 /src/base-object.h
parentb33a47ef473c169be2f11a2ee434f0f89ea1d106 (diff)
downloadandroid-node-v8-8e6706ea95c81534357c84237f561a0a8073c38e.tar.gz
android-node-v8-8e6706ea95c81534357c84237f561a0a8073c38e.tar.bz2
android-node-v8-8e6706ea95c81534357c84237f561a0a8073c38e.zip
src: update and expand comments in base-object.h
It's safe to call BaseObject::object() from your destructor _unless_ the handle is weak; then it's the weak callback that is calling your destructor and the object will have been released by the time the destructor runs. Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/base-object.h')
-rw-r--r--src/base-object.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/base-object.h b/src/base-object.h
index 3a18a4fde4..0e0df3e938 100644
--- a/src/base-object.h
+++ b/src/base-object.h
@@ -32,10 +32,15 @@ class BaseObject {
BaseObject(Environment* env, v8::Local<v8::Object> handle);
~BaseObject();
- // Returns the wrapped object. Illegal to call in your destructor.
+ // Returns the wrapped object. Returns an empty handle when
+ // persistent.IsEmpty() is true.
inline v8::Local<v8::Object> object();
- // Parent class is responsible to Dispose.
+ // The parent class is responsible for calling .Reset() on destruction
+ // when the persistent handle is strong because there is no way for
+ // BaseObject to know when the handle goes out of scope.
+ // Weak handles have been reset by the time the destructor runs but
+ // calling .Reset() again is harmless.
inline v8::Persistent<v8::Object>& persistent();
inline Environment* env() const;