From 6d22ae36302a9f86d417f1eb35b1ca694b468e9d Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Tue, 16 Jun 2020 12:27:14 -0700 Subject: [PATCH] doc: document n-api callback scope usage Document that it is not necessary to open handle and/or callback scopes inside finalizer, async work, thread-safe function etc. callbacks unless for reasons documented in the section about object lifetime management. Link usage of callback signatures to their definition. Fixes: https://github.com/nodejs/node/issues/33893 PR-URL: https://github.com/nodejs/node/pull/33915 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Chengzhong Wu Reviewed-By: Michael Dawson --- doc/api/n-api.md | 52 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 23262c853fcf41..207f840257ebaa 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -389,6 +389,7 @@ napi_status napi_set_instance_data(napi_env env, * `[in] data`: The data item to make available to bindings of this instance. * `[in] finalize_cb`: The function to call when the environment is being torn down. The function receives `data` so that it might free it. + [`napi_finalize`][] provides more details. * `[in] finalize_hint`: Optional hint to pass to the finalize callback during collection. @@ -592,6 +593,7 @@ minimum lifetimes explicitly. For more details, review the [Object lifetime management][]. ### N-API callback types + #### napi_callback_info