Skip to content

Commit

Permalink
doc: fix n-api asynchronous threading docs
Browse files Browse the repository at this point in the history
Documentation for N-API Custom Asynchronous Operations incorrectly
stated that async execution happens on the main event loop.
Added details to napi_create_async_work about which threads are
used to invoke the execute and complete callbacks.

Changed 'async' to 'asynchronous' in the documentation for Custom
Asynchronous Operations. Changed "executes in parallel" to "can
execute in parallel" for the documentation of napi_create_async_work
execute parameter.

Backport-PR-URL: #19265
PR-URL: #19073
Fixes: #19071
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
ebickle authored and MylesBorins committed May 1, 2018
1 parent cb3f90a commit 1abb168
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3283,9 +3283,11 @@ napi_status napi_create_async_work(napi_env env,
- `[in] async_resource_name`: 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.
the logic asynchronously. The given function is called from a worker pool
thread and can execute in parallel with the main event loop thread.
- `[in] complete`: The native function which will be called when the
asynchronous logic is comple or is cancelled.
asynchronous logic is completed or is cancelled. The given function is called
from the main event loop thread.
- `[in] data`: User-provided data context. This will be passed back into the
execute and complete functions.
- `[out] result`: `napi_async_work*` which is the handle to the newly created
Expand Down Expand Up @@ -3361,9 +3363,9 @@ callback invocation, even if it has been successfully cancelled.

## Custom Asynchronous Operations
The simple asynchronous work APIs above may not be appropriate for every
scenario, because with those the async execution still happens on the main
event loop. When using any other async mechanism, the following APIs are
necessary to ensure an async operation is properly tracked by the runtime.
scenario. When using any other asynchronous mechanism, the following APIs
are necessary to ensure an asynchronous operation is properly tracked by
the runtime.

### napi_async_init
<!-- YAML
Expand Down

0 comments on commit 1abb168

Please sign in to comment.