@@ -808,11 +808,11 @@ When an exception is pending one of two approaches can be employed.
808
808
809
809
The first approach is to do any appropriate cleanup and then return so that
810
810
execution will return to JavaScript. As part of the transition back to
811
- JavaScript the exception will be thrown at the point in the JavaScript
811
+ JavaScript, the exception will be thrown at the point in the JavaScript
812
812
code where the native method was invoked. The behavior of most N-API calls
813
813
is unspecified while an exception is pending, and many will simply return
814
- `napi_pending_exception`, so it is important to do as little as possible
815
- and then return to JavaScript where the exception can be handled.
814
+ `napi_pending_exception`, so do as little as possible and then return to
815
+ JavaScript where the exception can be handled.
816
816
817
817
The second approach is to try to handle the exception. There will be cases
818
818
where the native code can catch the exception, take the appropriate action,
@@ -4318,8 +4318,7 @@ required in order to enable correct disposal of the reference.
4318
4318
Addon modules often need to leverage async helpers from libuv as part of their
4319
4319
implementation. This allows them to schedule work to be executed asynchronously
4320
4320
so that their methods can return in advance of the work being completed. This
4321
- is important in order to allow them to avoid blocking overall execution
4322
- of the Node.js application.
4321
+ allows them to avoid blocking overall execution of the Node.js application.
4323
4322
4324
4323
N-API provides an ABI-stable interface for these
4325
4324
supporting functions which covers the most common asynchronous use cases.
@@ -4922,9 +4921,9 @@ Upon creation of a `napi_threadsafe_function` a `napi_finalize` callback can be
4922
4921
provided. This callback will be invoked on the main thread when the thread-safe
4923
4922
function is about to be destroyed. It receives the context and the finalize data
4924
4923
given during construction, and provides an opportunity for cleaning up after the
4925
- threads e.g. by calling `uv_thread_join()`. **It is important that, aside from
4926
- the main loop thread, there be no threads left using the thread-safe function
4927
- after the finalize callback completes.**
4924
+ threads e.g. by calling `uv_thread_join()`. **Aside from the main loop thread,
4925
+ no threads should be using the thread-safe function after the finalize callback
4926
+ completes.**
4928
4927
4929
4928
The `context` given during the call to `napi_create_threadsafe_function()` can
4930
4929
be retrieved from any thread with a call to
@@ -4969,13 +4968,13 @@ existing thread will stop making use of the thread-safe function.
4969
4968
the object has called `napi_release_threadsafe_function()` or has received a
4970
4969
return status of `napi_closing` in response to a call to
4971
4970
`napi_call_threadsafe_function`. The queue is emptied before the
4972
- `napi_threadsafe_function` is destroyed. It is important that
4973
- `napi_release_threadsafe_function()` be the last API call made in conjunction
4974
- with a given `napi_threadsafe_function`, because after the call completes, there
4975
- is no guarantee that the `napi_threadsafe_function` is still allocated. For the
4976
- same reason it is also important that no more use be made of a thread-safe
4977
- function after receiving a return value of `napi_closing` in response to a call
4978
- to `napi_call_threadsafe_function`. Data associated with the
4971
+ `napi_threadsafe_function` is destroyed. `napi_release_threadsafe_function()`
4972
+ should be the last API call made in conjunction with a given
4973
+ `napi_threadsafe_function`, because after the call completes, there is no
4974
+ guarantee that the `napi_threadsafe_function` is still allocated. For the same
4975
+ reason, do not make use of a thread-safe function
4976
+ after receiving a return value of `napi_closing` in response to a call to
4977
+ `napi_call_threadsafe_function`. Data associated with the
4979
4978
`napi_threadsafe_function` can be freed in its `napi_finalize` callback which
4980
4979
was passed to `napi_create_threadsafe_function()`.
4981
4980
0 commit comments