diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-09-09 22:28:02 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-05-10 14:15:16 +0200 |
commit | 5c6cf30143f3191b043ba0b4e814768efa1069f7 (patch) | |
tree | 630c9aed6f50ee77ebdca48293d16155b36c0d86 /src/node_api.h | |
parent | 560925fe22bfc23860b04704ff4cae21e4dd19ff (diff) | |
download | android-node-v8-5c6cf30143f3191b043ba0b4e814768efa1069f7.tar.gz android-node-v8-5c6cf30143f3191b043ba0b4e814768efa1069f7.tar.bz2 android-node-v8-5c6cf30143f3191b043ba0b4e814768efa1069f7.zip |
src: add environment cleanup hooks
This adds pairs of methods to the `Environment` class and to public APIs
which can add and remove cleanup handlers.
Unlike `AtExit`, this API targets addon developers rather than
embedders, giving them (and Node’s internals) the ability to register
per-`Environment` cleanup work.
We may want to replace `AtExit` with this API at some point.
Many thanks for Stephen Belanger for reviewing the original version of
this commit in the Ayo.js project.
Refs: https://github.com/ayojs/ayo/pull/82
PR-URL: https://github.com/nodejs/node/pull/19377
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_api.h')
-rw-r--r-- | src/node_api.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/node_api.h b/src/node_api.h index b010d32db7..91c2775a03 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -118,6 +118,13 @@ EXTERN_C_START NAPI_EXTERN void napi_module_register(napi_module* mod); +NAPI_EXTERN napi_status napi_add_env_cleanup_hook(napi_env env, + void (*fun)(void* arg), + void* arg); +NAPI_EXTERN napi_status napi_remove_env_cleanup_hook(napi_env env, + void (*fun)(void* arg), + void* arg); + NAPI_EXTERN napi_status napi_get_last_error_info(napi_env env, const napi_extended_error_info** result); |