Skip to content
Closed
Changes from all commits
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
n-api: make thread-safe-function calls properly
Use `NapiCallIntoModuleThrow()` to execute the call into JavaScript and
the finalizer for consistency with the rest of the calls into the N-API
addon.
  • Loading branch information
Gabriel Schulhof
Gabriel Schulhof committed Jul 9, 2019
commit 24a96bc6e6d576caba1f1c8603338038099b03b9
11 changes: 6 additions & 5 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,9 @@ class ThreadSafeFunction : public node::AsyncResource {
v8::Local<v8::Function>::New(env->isolate, ref);
js_callback = v8impl::JsValueFromV8LocalValue(js_cb);
}
call_js_cb(env,
js_callback,
context,
data);
NapiCallIntoModuleThrow(env, [&]() {
call_js_cb(env, js_callback, context, data);
});
}
}
}
Expand All @@ -347,7 +346,9 @@ class ThreadSafeFunction : public node::AsyncResource {
v8::HandleScope scope(env->isolate);
if (finalize_cb) {
CallbackScope cb_scope(this);
finalize_cb(env, finalize_data, context);
NapiCallIntoModuleThrow(env, [&]() {
finalize_cb(env, finalize_data, context);
});
}
EmptyQueueAndDelete();
}
Expand Down