diff options
| author | 8cy <[email protected]> | 2020-04-03 02:48:28 -0700 |
|---|---|---|
| committer | 8cy <[email protected]> | 2020-04-03 02:48:28 -0700 |
| commit | f9159ea2d994e14180fb02ab562f0119513e67cf (patch) | |
| tree | 09d14cdf05456567156738b681379d4bccd64e5c /node_modules/node-addon-api/doc/async_operations.md | |
| parent | 2020/04/03, 02:42, V1.2.1 (diff) | |
| download | s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.tar.xz s5nical-f9159ea2d994e14180fb02ab562f0119513e67cf.zip | |
2020/04/03, 02:47, V1.2.2
Diffstat (limited to 'node_modules/node-addon-api/doc/async_operations.md')
| -rw-r--r-- | node_modules/node-addon-api/doc/async_operations.md | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/node_modules/node-addon-api/doc/async_operations.md b/node_modules/node-addon-api/doc/async_operations.md deleted file mode 100644 index 064a9c5..0000000 --- a/node_modules/node-addon-api/doc/async_operations.md +++ /dev/null @@ -1,31 +0,0 @@ -# Asynchronous operations - -Node.js native add-ons often need to execute long running tasks and to avoid -blocking the **event loop** they have to run them asynchronously from the -**event loop**. -In the Node.js model of execution the event loop thread represents the thread -where JavaScript code is executing. The Node.js guidance is to avoid blocking -other work queued on the event loop thread. Therefore, we need to do this work on -another thread. - -All this means that native add-ons need to leverage async helpers from libuv as -part of their implementation. This allows them to schedule work to be executed -asynchronously so that their methods can return in advance of the work being -completed. - -Node Addon API provides an interface to support functions that cover -the most common asynchronous use cases. There is an abstract classes to implement -asynchronous operations: - -- **[`Napi::AsyncWorker`](async_worker.md)** - -These class helps manage asynchronous operations through an abstraction -of the concept of moving data between the **event loop** and **worker threads**. - -Also, the above class may not be appropriate for every scenario. When using any -other asynchronous mechanism, the following API is necessary to ensure an -asynchronous operation is properly tracked by the runtime: - -- **[AsyncContext](async_context.md)** - -- **[CallbackScope](callback_scope.md)** |