From d64e4deb737a91654ff683d6cc00d0419374df5e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 21 Feb 2019 19:22:44 +0100 Subject: [PATCH] src: simplify native immediate by using v8::Global Unlike `node::Persistent`, `v8::Global` has move semantics and can be used directly in STL containers. PR-URL: https://github.com/nodejs/node/pull/26254 Reviewed-By: Gus Caplan Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis Reviewed-By: Joyee Cheung Reviewed-By: James M Snell --- src/env-inl.h | 3 +-- src/env.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index 9752613b292..824b7529a99 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -625,8 +625,7 @@ void Environment::CreateImmediate(native_immediate_callback cb, native_immediate_callbacks_.push_back({ cb, data, - std::unique_ptr>(obj.IsEmpty() ? - nullptr : new Persistent(isolate_, obj)), + v8::Global(isolate_, obj), ref }); immediate_info()->count_inc(1); diff --git a/src/env.h b/src/env.h index 6f09187f9ce..92db65525e0 100644 --- a/src/env.h +++ b/src/env.h @@ -1139,7 +1139,7 @@ class Environment { struct NativeImmediateCallback { native_immediate_callback cb_; void* data_; - std::unique_ptr> keep_alive_; + v8::Global keep_alive_; bool refed_; }; std::vector native_immediate_callbacks_;