Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
src: simplify native immediate by using v8::Global
Unlike `node::Persistent`, `v8::Global` has move semantics and
can be used directly in STL containers.
  • Loading branch information
addaleax committed Feb 21, 2019
commit 87419bea0381a58eec05fdd8de4e42ae758340db
4 changes: 2 additions & 2 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,8 @@ 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)),
obj.IsEmpty() ? v8::Global<v8::Object>() :
v8::Global<v8::Object>(isolate_, obj),
Comment thread
addaleax marked this conversation as resolved.
Outdated
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 @@ -1092,7 +1092,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