n-api,src: provide asynchronous cleanup hooks
Sometimes addons need to perform cleanup actions, for example closing libuv handles or waiting for requests to finish, that cannot be performed synchronously.
Add C++ API and N-API functions that allow providing such asynchronous cleanup hooks.
Fixes: https://github.com/nodejs/node/issues/34567
@nodejs/n-api
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