napi_acquire_threadsafe_function


NAPI_EXTERN napi_status
napi_acquire_threadsafe_function(napi_threadsafe_function func); 
  • [in] func:用于开始使用的异步线程安全的 JavaScript 函数。

线程在将 func 传递给任何其他线程安全的函数 API 之前,应先调用此 API,以表明它将使用 func。这可以防止在所有其他线程不再使用 func 时,func 被销毁。

【A thread should call this API before passing func to any other thread-safe function APIs to indicate that it will be making use of func. This prevents func from being destroyed when all other threads have stopped making use of it.】

此 API 可以从任何线程调用,该线程将开始使用 func

【This API may be called from any thread which will start making use of func.】