Skip to content
Permalink
Browse files

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: #26254
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
addaleax authored and BethGriggs committed Feb 21, 2019
1 parent 4f60364 commit 55d3be7e9e50f651e1f1419c2f60a548892931d7
Showing with 2 additions and 3 deletions.
  1. +1 −2 src/env-inl.h
  2. +1 −1 src/env.h
@@ -590,8 +590,7 @@ void Environment::CreateImmediate(native_immediate_callback cb,
native_immediate_callbacks_.push_back({
cb,
data,
std::unique_ptr<Persistent<v8::Object>>(obj.IsEmpty() ?
nullptr : new Persistent<v8::Object>(isolate_, obj)),
v8::Global<v8::Object>(isolate_, obj),
ref
});
immediate_info()->count_inc(1);
@@ -977,7 +977,7 @@ class Environment {
struct NativeImmediateCallback {
native_immediate_callback cb_;
void* data_;
std::unique_ptr<Persistent<v8::Object>> keep_alive_;
v8::Global<v8::Object> keep_alive_;
bool refed_;
};
std::vector<NativeImmediateCallback> native_immediate_callbacks_;

0 comments on commit 55d3be7

Please sign in to comment.
You can’t perform that action at this time.