summaryrefslogtreecommitdiff
path: root/doc/api/addons.md
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-12-05 17:23:56 -0800
committerGabriel Schulhof <gabriel.schulhof@intel.com>2018-12-19 18:34:28 -0800
commit622e348d8f70a4ec006ee1ce9207a6a5bc3fc325 (patch)
tree83bdaaabb0acad67cb1c538f367ecace121a522a /doc/api/addons.md
parentbf36f0755c0a41702fe506bcfc90d156030d0497 (diff)
downloadandroid-node-v8-622e348d8f70a4ec006ee1ce9207a6a5bc3fc325.tar.gz
android-node-v8-622e348d8f70a4ec006ee1ce9207a6a5bc3fc325.tar.bz2
android-node-v8-622e348d8f70a4ec006ee1ce9207a6a5bc3fc325.zip
test,doc: add tests and docs for addon unloading
Originally from portions of https://github.com/nodejs/node/pull/23319/. PR-URL: https://github.com/nodejs/node/pull/24861 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'doc/api/addons.md')
-rw-r--r--doc/api/addons.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/api/addons.md b/doc/api/addons.md
index d993c72d34..9bc75c7dfc 100644
--- a/doc/api/addons.md
+++ b/doc/api/addons.md
@@ -234,6 +234,23 @@ NODE_MODULE_INIT(/* exports, module, context */) {
}
```
+#### Worker support
+
+In order to support [`Worker`][] threads, addons need to clean up any resources
+they may have allocated when such a thread exists. This can be achieved through
+the usage of the `AddEnvironmentCleanupHook()` function:
+
+```c++
+void AddEnvironmentCleanupHook(v8::Isolate* isolate,
+ void (*fun)(void* arg),
+ void* arg);
+```
+
+This function adds a hook that will run before a given Node.js instance shuts
+down. If necessary, such hooks can be removed using
+`RemoveEnvironmentCleanupHook()` before they are run, which has the same
+signature.
+
### Building
Once the source code has been written, it must be compiled into the binary
@@ -1349,6 +1366,7 @@ Test in JavaScript by running:
require('./build/Release/addon');
```
+[`Worker`]: worker_threads.html#worker_threads_class_worker
[Electron]: https://electronjs.org/
[Embedder's Guide]: https://github.com/v8/v8/wiki/Embedder's%20Guide
[Linking to Node.js' own dependencies]: #addons_linking_to_node_js_own_dependencies