diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-04-18 00:16:22 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-04-30 01:23:33 +0300 |
commit | 723d5c058fa180684df13bd2a83bbf3ca6201957 (patch) | |
tree | 6aeb4bc88e6c437853327cced05ab797827c22f2 /src/base_object.h | |
parent | 095bd569aef4fec433ddb26e681eaabff1f7fd10 (diff) |
src: prefer v8::Global over node::Persistent
`v8::Global` is essentially a nicer variant of `node::Persistent` that,
in addition to reset-on-destroy, also implements move semantics.
This commit makes the necessary replacements, removes
`node::Persistent` and (now-)unnecessary inclusions of the
`node_persistent.h` header, and makes some of the functions that
take Persistents as arguments more generic so that they work with all
`v8::PersistentBase` flavours.
PR-URL: https://github.com/nodejs/node/pull/27287
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/base_object.h')
-rw-r--r-- | src/base_object.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/base_object.h b/src/base_object.h index f1c666224f0..cb83462ff51 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -24,7 +24,6 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS -#include "node_persistent.h" #include "memory_tracker-inl.h" #include "v8.h" #include <type_traits> // std::remove_reference @@ -50,7 +49,7 @@ class BaseObject : public MemoryRetainer { // is associated with the passed Isolate in debug mode. inline v8::Local<v8::Object> object(v8::Isolate* isolate) const; - inline Persistent<v8::Object>& persistent(); + inline v8::Global<v8::Object>& persistent(); inline Environment* env() const; @@ -62,7 +61,7 @@ class BaseObject : public MemoryRetainer { template <typename T> static inline T* FromJSObject(v8::Local<v8::Object> object); - // Make the `Persistent` a weak reference and, `delete` this object once + // Make the `v8::Global` a weak reference and, `delete` this object once // the JS object has been garbage collected. inline void MakeWeak(); @@ -96,7 +95,7 @@ class BaseObject : public MemoryRetainer { friend int GenDebugSymbols(); friend class CleanupHookCallback; - Persistent<v8::Object> persistent_handle_; + v8::Global<v8::Object> persistent_handle_; Environment* env_; }; |