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. PR-URL: https://github.com/nodejs/node/pull/28606 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
This commit is contained in:
parent
e800f9d68a
commit
f5b40b2ffa
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user