From 06d592c551843e3d1f129086ef6293c511c6af59 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 9752613b292368..824b7529a9945d 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 f0c57fe3fb60f8..87b2d3abd38cd8 100644 --- a/src/env.h +++ b/src/env.h @@ -1143,7 +1143,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_;