napi_ref_threadsafe_function
NAPI_EXTERN napi_status
napi_ref_threadsafe_function(node_api_basic_env env, napi_threadsafe_function func); [in] env:调用该 API 时所处的环境。[in] func:要引用的线程安全函数。
此 API 用于指示在主线程上运行的事件循环在 func 被销毁之前不应退出。与 uv_ref 类似,它也是幂等的。
【This API is used to indicate that the event loop running on the main thread
should not exit until func has been destroyed. Similar to uv_ref it is
also idempotent.】
napi_unref_threadsafe_function 并不会将线程安全函数标记为可销毁,napi_ref_threadsafe_function 也不会阻止其被销毁。napi_acquire_threadsafe_function 和 napi_release_threadsafe_function 可用于该目的。
【Neither does napi_unref_threadsafe_function mark the thread-safe functions as
able to be destroyed nor does napi_ref_threadsafe_function prevent it from
being destroyed. napi_acquire_threadsafe_function and
napi_release_threadsafe_function are available for that purpose.】
此 API 只能从主线程调用。
【This API may only be called from the main thread.】