Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: clarify async execute callback usage
Clarify that calls to N-API should be avoided in
the 'execute' callback.

Refs: nodejs/help#1318
  • Loading branch information
mhdawson committed Jun 8, 2018
commit e11e8fd2e61c381d2c8b0dc8b41527ce85ad4136
14 changes: 13 additions & 1 deletion doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ operations. Callback functions must statisfy the following signature:
typedef void (*napi_async_execute_callback)(napi_env env, void* data);
```

Implementations of this type of function should avoid making any N-API calls
that could result in the execution of JavaScript or interaction with
JavaScript objects. Most often any code that needs to make N-API
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro-nit: comma after often

calls should be made in `napi_async_complete_callback` instead.

#### napi_async_complete_callback
Function pointer used with functions that support asynchronous
operations. Callback functions must statisfy the following signature:
Expand Down Expand Up @@ -3322,7 +3327,14 @@ asynchronous workers. Instances are created/deleted with

The `execute` and `complete` callbacks are functions that will be
invoked when the executor is ready to execute and when it completes its
task respectively. These functions implement the following interfaces:
task respectively.

The `execute` function should avoid making any N-API calls
that could result in the execution of JavaScript or interaction with
JavaScript objects. Most often any code that needs to make N-API
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

calls should be made in `complete` callback instead.

These functions implement the following interfaces:

```C
typedef void (*napi_async_execute_callback)(napi_env env,
Expand Down