From 151a914c99a7b2644b25799223be9d954a4ece57 Mon Sep 17 00:00:00 2001 From: Kevin Eady <8634912+KevinEady@users.noreply.github.com> Date: Fri, 9 Oct 2020 11:23:37 +0200 Subject: [PATCH] Apply documentation suggestions from code review Documentation updates Co-authored-by: Gabriel Schulhof --- doc/threadsafe_function_ex.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/threadsafe_function_ex.md b/doc/threadsafe_function_ex.md index 497484397..b0df5a8c0 100644 --- a/doc/threadsafe_function_ex.md +++ b/doc/threadsafe_function_ex.md @@ -7,7 +7,7 @@ of: - `ContextType = std::nullptr_t`: The thread-safe function's context. By default, a TSFN has no context. - `DataType = void*`: The data to use in the native callback. By default, a TSFN - can accept *any* data type. + can accept any data type. - `Callback = void(*)(Napi::Env, Napi::Function jsCallback, ContextType*, DataType*)`: The callback to run for each item added to the queue. If no `Callback` is given, the API will call the function `jsCallback` with no @@ -102,7 +102,7 @@ When targetting version 5+, `callback` may be: ### Acquire -Add a thread to this thread-safe function object, indicating that a new thread +Adds a thread to this thread-safe function object, indicating that a new thread will start making use of the thread-safe function. ```cpp @@ -117,10 +117,10 @@ Returns one of: ### Release -Indicate that an existing thread will stop making use of the thread-safe +Indicates that an existing thread will stop making use of the thread-safe function. A thread should call this API when it stops making use of this thread-safe function. Using any thread-safe APIs after having called this API -has undefined results in the current thread, as it may have been destroyed. +has undefined results in the current thread, as the thread-safe function may have been destroyed. ```cpp napi_status Napi::ThreadSafeFunctionEx::Release() @@ -134,7 +134,7 @@ Returns one of: ### Abort -"Abort" the thread-safe function. This will cause all subsequent APIs associated +"Aborts" the thread-safe function. This will cause all subsequent APIs associated with the thread-safe function except `Release()` to return `napi_closing` even before its reference count reaches zero. In particular, `BlockingCall` and `NonBlockingCall()` will return `napi_closing`, thus informing the threads that @@ -173,11 +173,10 @@ napi_status Napi::ThreadSafeFunctionEx::NonBloc `ThreadSafeFunctionEx::New()`. Returns one of: -- `napi_ok`: The call was successfully added to the queue. +- `napi_ok`: `data` was successfully added to the queue. - `napi_queue_full`: The queue was full when trying to call in a non-blocking method. -- `napi_closing`: The thread-safe function is aborted and cannot accept more - calls. +- `napi_closing`: The thread-safe function is aborted and no further calls can be made. - `napi_invalid_arg`: The thread-safe function is closed. - `napi_generic_failure`: A generic error occurred when attemping to add to the queue.