From b8a17ccc9a5e835e50fcee5592c5d8abffde1321 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 902cb883aeec92..d1fa23260f178f 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -391,6 +391,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. @@ -597,6 +598,7 @@ minimum lifetimes explicitly. For more details, review the [Object lifetime management][]. ### N-API callback types + #### napi_callback_info