napi_acquire_threadsafe_function


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

    ¥[in] func: The asynchronous thread-safe JavaScript function to start making use of.

线程应在将 func 传递给任何其他线程安全函数 API 以指示它将使用 func 之前调用此 API。这可以防止 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.

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

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