napi_release_threadsafe_function
NAPI_EXTERN napi_status
napi_release_threadsafe_function(napi_threadsafe_function func,
napi_threadsafe_function_release_mode mode);
-
[in] func
:异步线程安全的 JavaScript 函数,其引用计数将减少。¥
[in] func
: The asynchronous thread-safe JavaScript function whose reference count to decrement. -
[in] mode
:其值可以是napi_tsfn_release
的标志,表示当前线程将不再调用线程安全函数,或者是napi_tsfn_abort
,表示除了当前线程之外,没有其他线程应该进一步调用线程安全函数 功能。如果设置为napi_tsfn_abort
,对napi_call_threadsafe_function()
的进一步调用将返回napi_closing
,并且不会将更多值放入队列中。¥
[in] mode
: Flag whose value can be eithernapi_tsfn_release
to indicate that the current thread will make no further calls to the thread-safe function, ornapi_tsfn_abort
to indicate that in addition to the current thread, no other thread should make any further calls to the thread-safe function. If set tonapi_tsfn_abort
, further calls tonapi_call_threadsafe_function()
will returnnapi_closing
, and no further values will be placed in the queue.
线程停止使用 func
时应调用此 API。在调用此 API 后将 func
传递给任何线程安全的 API 会产生未定义的结果,因为 func
可能已被销毁。
¥A thread should call this API when it stops making use of func
. Passing func
to any thread-safe APIs after having called this API has undefined results, as
func
may have been destroyed.
可以从任何将停止使用 func
的线程调用此 API。
¥This API may be called from any thread which will stop making use of func
.