Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a4462b7

Browse filesBrowse files
ebickleaddaleax
authored andcommitted
doc: fix n-api asynchronous threading docs
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. 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>
1 parent bfa894c commit a4462b7
Copy full SHA for a4462b7

File tree

Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-5
lines changed
Open diff view settings
Collapse file

‎doc/api/n-api.md‎

Copy file name to clipboardExpand all lines: doc/api/n-api.md
+7-5Lines changed: 7 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3268,9 +3268,11 @@ napi_status napi_create_async_work(napi_env env,
32683268
- `[in] async_resource_name`: Identifier for the kind of resource that is
32693269
being provided for diagnostic information exposed by the `async_hooks` API.
32703270
- `[in] execute`: The native function which should be called to excute
3271-
the logic asynchronously.
3271+
the logic asynchronously. The given function is called from a worker pool
3272+
thread and can execute in parallel with the main event loop thread.
32723273
- `[in] complete`: The native function which will be called when the
3273-
asynchronous logic is comple or is cancelled.
3274+
asynchronous logic is completed or is cancelled. The given function is called
3275+
from the main event loop thread.
32743276
- `[in] data`: User-provided data context. This will be passed back into the
32753277
execute and complete functions.
32763278
- `[out] result`: `napi_async_work*` which is the handle to the newly created
@@ -3346,9 +3348,9 @@ callback invocation, even if it has been successfully cancelled.
33463348

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

33533355
### napi_async_init
33543356
<!-- YAML

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.