From b013fbd4dcdfcf2b304a6d89c95f75306b975612 Mon Sep 17 00:00:00 2001 From: toyobayashi Date: Fri, 20 Jan 2023 20:48:22 +0800 Subject: [PATCH] tsfn ref & unref --- packages/emnapi/src/emnapi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/emnapi/src/emnapi.c b/packages/emnapi/src/emnapi.c index a2b87166..44a158f5 100644 --- a/packages/emnapi/src/emnapi.c +++ b/packages/emnapi/src/emnapi.c @@ -533,6 +533,7 @@ _emnapi_tsfn_create(napi_env env, _emnapi_env_ref(env); EMNAPI_KEEPALIVE_PUSH(); + _emnapi_ctx_increase_waiting_request_counter(); ts_fn->async_ref = true; return ts_fn; } @@ -560,6 +561,7 @@ static void _emnapi_tsfn_destroy(napi_threadsafe_function func) { _emnapi_env_unref(func->env); if (func->async_ref) { EMNAPI_KEEPALIVE_POP(); + _emnapi_ctx_decrease_waiting_request_counter(); func->async_ref = false; } @@ -923,6 +925,7 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func) { #ifdef __EMSCRIPTEN_PTHREADS__ if (func->async_ref) { EMNAPI_KEEPALIVE_POP(); + _emnapi_ctx_decrease_waiting_request_counter(); func->async_ref = false; } return napi_ok; @@ -936,6 +939,7 @@ napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func) { #ifdef __EMSCRIPTEN_PTHREADS__ if (!func->async_ref) { EMNAPI_KEEPALIVE_PUSH(); + _emnapi_ctx_increase_waiting_request_counter(); func->async_ref = true; } return napi_ok;