Skip to content

Commit

Permalink
src: simplify native immediate by using v8::Global
Browse files Browse the repository at this point in the history
Unlike `node::Persistent`, `v8::Global` has move semantics and
can be used directly in STL containers.

PR-URL: #26254
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax committed Mar 2, 2019
1 parent ea26ac0 commit 06d592c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,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);
Expand Down
2 changes: 1 addition & 1 deletion src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,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_;
Expand Down

0 comments on commit 06d592c

Please sign in to comment.