diff options
author | Anna Henningsen <anna@addaleax.net> | 2017-08-08 20:18:16 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-09-14 17:38:45 +0200 |
commit | 8c8c90b714756433b3333146a2893572b473dfd6 (patch) | |
tree | bb10f495f0bf76e50f2f144b8e657097463f0e3a /doc/api/n-api.md | |
parent | a564c1eb20a6742a50dca283312d9881a8f1fca6 (diff) | |
download | android-node-v8-8c8c90b714756433b3333146a2893572b473dfd6.tar.gz android-node-v8-8c8c90b714756433b3333146a2893572b473dfd6.tar.bz2 android-node-v8-8c8c90b714756433b3333146a2893572b473dfd6.zip |
n-api: use AsyncResource for Work tracking
Enable combining N-API async work with async-hooks.
PR-URL: https://github.com/nodejs/node/pull/14697
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
Reviewed-By: Michael Dawson <mhdawson@ibm.com>
Diffstat (limited to 'doc/api/n-api.md')
-rw-r--r-- | doc/api/n-api.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/api/n-api.md b/doc/api/n-api.md index b9d06079fd..0a74d89ea0 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -3256,10 +3256,16 @@ callback invocation, even when it was cancelled. ### napi_create_async_work <!-- YAML added: v8.0.0 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/14697 + description: Added `async_resource` and `async_resource_name` parameters. --> ```C NAPI_EXTERN napi_status napi_create_async_work(napi_env env, + napi_value async_resource, + const char* async_resource_name, napi_async_execute_callback execute, napi_async_complete_callback complete, void* data, @@ -3267,6 +3273,10 @@ napi_status napi_create_async_work(napi_env env, ``` - `[in] env`: The environment that the API is invoked under. +- `[in] async_resource`: An optional object associated with the async work + that will be passed to possible async_hooks [`init` hooks][]. +- `[in] async_resource_name`: An identifier for the kind of resource that is +being provided for diagnostic information exposed by the `async_hooks` API. - `[in] execute`: The native function which should be called to excute the logic asynchronously. - `[in] complete`: The native function which will be called when the @@ -3282,6 +3292,14 @@ This API allocates a work object that is used to execute logic asynchronously. It should be freed using [`napi_delete_async_work`][] once the work is no longer required. +`async_resource_name` should be a null-terminated, UTF-8-encoded string. + +*Note*: The `async_resource_name` identifier is provided by the user and should +be representative of the type of async work being performed. It is also +recommended to apply namespacing to the identifier, e.g. by including the +module name. See the [`async_hooks` documentation][async_hooks `type`] +for more information. + ### napi_delete_async_work <!-- YAML added: v8.0.0 @@ -3636,3 +3654,5 @@ NAPI_EXTERN napi_status napi_run_script(napi_env env, [`napi_wrap`]: #n_api_napi_wrap [`process.release`]: process.html#process_process_release +[`init` hooks]: async_hooks.html#async_hooks_init_asyncid_type_triggerasyncid_resource +[async_hooks `type`]: async_hooks.html#async_hooks_type |