n-api: add API for asynchronous functions (simpler version)
Bundle a uv_async_t
and a napi_ref
to make it possible to call into
JS from another thread. The API accepts a void data pointer and a
callback which will be invoked on the loop thread and which will
receive the napi_value
resulting from the napi_ref
so as to perform
the call into JS. The callback is run inside a node::CallbackScope
.
Fixes: https://github.com/nodejs/node/issues/13512
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
n-api
This is an alternative, and perhaps simpler implementation of napi_threadsafe_function
, alternative to https://github.com/nodejs/node/pull/17809/