Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-07-31 03:10:14 +0300
committerAnna Henningsen <anna@addaleax.net>2020-08-07 01:02:02 +0300
commit22cbbcf9d9374d4b663bf1409f292212fa57623a (patch)
tree59a9e22bdae3900b961e4c58f53aa6c9b0a511bd /src/node_api.h
parenta4e1755df2f9bb8c712d7ca767a5944d9d71e33b (diff)
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 PR-URL: https://github.com/nodejs/node/pull/34572 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Diffstat (limited to 'src/node_api.h')
-rw-r--r--src/node_api.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/node_api.h b/src/node_api.h
index 2f1b45572d8..4f3eb8f2caa 100644
--- a/src/node_api.h
+++ b/src/node_api.h
@@ -250,6 +250,20 @@ napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
#endif // NAPI_VERSION >= 4
+#ifdef NAPI_EXPERIMENTAL
+
+NAPI_EXTERN napi_status napi_add_async_cleanup_hook(
+ napi_env env,
+ void (*fun)(void* arg, void(* cb)(void*), void* cbarg),
+ void* arg,
+ napi_async_cleanup_hook_handle* remove_handle);
+
+NAPI_EXTERN napi_status napi_remove_async_cleanup_hook(
+ napi_env env,
+ napi_async_cleanup_hook_handle remove_handle);
+
+#endif // NAPI_EXPERIMENTAL
+
EXTERN_C_END
#endif // SRC_NODE_API_H_