@@ -810,11 +810,11 @@ When an exception is pending one of two approaches can be employed.
810
810
811
811
The first approach is to do any appropriate cleanup and then return so that
812
812
execution will return to JavaScript. As part of the transition back to
813
- JavaScript the exception will be thrown at the point in the JavaScript
813
+ JavaScript, the exception will be thrown at the point in the JavaScript
814
814
code where the native method was invoked. The behavior of most N-API calls
815
815
is unspecified while an exception is pending, and many will simply return
816
- `napi_pending_exception`, so it is important to do as little as possible
817
- and then return to JavaScript where the exception can be handled.
816
+ `napi_pending_exception`, so do as little as possible and then return to
817
+ JavaScript where the exception can be handled.
818
818
819
819
The second approach is to try to handle the exception. There will be cases
820
820
where the native code can catch the exception, take the appropriate action,
@@ -4344,8 +4344,7 @@ required in order to enable correct disposal of the reference.
4344
4344
Addon modules often need to leverage async helpers from libuv as part of their
4345
4345
implementation. This allows them to schedule work to be executed asynchronously
4346
4346
so that their methods can return in advance of the work being completed. This
4347
- is important in order to allow them to avoid blocking overall execution
4348
- of the Node.js application.
4347
+ allows them to avoid blocking overall execution of the Node.js application.
4349
4348
4350
4349
N-API provides an ABI-stable interface for these
4351
4350
supporting functions which covers the most common asynchronous use cases.
@@ -4948,9 +4947,9 @@ Upon creation of a `napi_threadsafe_function` a `napi_finalize` callback can be
4948
4947
provided. This callback will be invoked on the main thread when the thread-safe
4949
4948
function is about to be destroyed. It receives the context and the finalize data
4950
4949
given during construction, and provides an opportunity for cleaning up after the
4951
- threads e.g. by calling `uv_thread_join()`. **It is important that, aside from
4952
- the main loop thread, there be no threads left using the thread-safe function
4953
- after the finalize callback completes.**
4950
+ threads e.g. by calling `uv_thread_join()`. **Aside from the main loop thread,
4951
+ no threads should be using the thread-safe function after the finalize callback
4952
+ completes.**
4954
4953
4955
4954
The `context` given during the call to `napi_create_threadsafe_function()` can
4956
4955
be retrieved from any thread with a call to
@@ -4995,13 +4994,13 @@ existing thread will stop making use of the thread-safe function.
4995
4994
the object has called `napi_release_threadsafe_function()` or has received a
4996
4995
return status of `napi_closing` in response to a call to
4997
4996
`napi_call_threadsafe_function`. The queue is emptied before the
4998
- `napi_threadsafe_function` is destroyed. It is important that
4999
- `napi_release_threadsafe_function()` be the last API call made in conjunction
5000
- with a given `napi_threadsafe_function`, because after the call completes, there
5001
- is no guarantee that the `napi_threadsafe_function` is still allocated. For the
5002
- same reason it is also important that no more use be made of a thread-safe
5003
- function after receiving a return value of `napi_closing` in response to a call
5004
- to `napi_call_threadsafe_function`. Data associated with the
4997
+ `napi_threadsafe_function` is destroyed. `napi_release_threadsafe_function()`
4998
+ should be the last API call made in conjunction with a given
4999
+ `napi_threadsafe_function`, because after the call completes, there is no
5000
+ guarantee that the `napi_threadsafe_function` is still allocated. For the same
5001
+ reason, do not make use of a thread-safe function
5002
+ after receiving a return value of `napi_closing` in response to a call to
5003
+ `napi_call_threadsafe_function`. Data associated with the
5005
5004
`napi_threadsafe_function` can be freed in its `napi_finalize` callback which
5006
5005
was passed to `napi_create_threadsafe_function()`.
5007
5006
0 commit comments