@@ -808,11 +808,11 @@ When an exception is pending one of two approaches can be employed.
808808
809809The first approach is to do any appropriate cleanup and then return so that
810810execution 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
812812code where the native method was invoked. The behavior of most N-API calls
813813is 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.
816816
817817The second approach is to try to handle the exception. There will be cases
818818where 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.
43184318Addon modules often need to leverage async helpers from libuv as part of their
43194319implementation. This allows them to schedule work to be executed asynchronously
43204320so 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.
43234322
43244323N-API provides an ABI-stable interface for these
43254324supporting 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
49224921provided. This callback will be invoked on the main thread when the thread-safe
49234922function is about to be destroyed. It receives the context and the finalize data
49244923given 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.**
49284927
49294928The `context` given during the call to `napi_create_threadsafe_function()` can
49304929be retrieved from any thread with a call to
@@ -4969,13 +4968,13 @@ existing thread will stop making use of the thread-safe function.
49694968the object has called `napi_release_threadsafe_function()` or has received a
49704969return status of `napi_closing` in response to a call to
49714970`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
49794978`napi_threadsafe_function` can be freed in its `napi_finalize` callback which
49804979was passed to `napi_create_threadsafe_function()`.
49814980
0 commit comments