From 09b88aabb3fd5cfd2da98ae83c2f1edd82d899c5 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Fri, 27 Jul 2018 16:17:32 +0200 Subject: [PATCH] n-api: remove idle_running from TsFn The idle_running member variable in TsFn is always false and can therefore be removed. Backport-PR-URL: https://github.com/nodejs/node/pull/25002 PR-URL: https://github.com/nodejs/node/pull/22520 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Gabriel Schulhof Reviewed-By: Gus Caplan --- src/node_api.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/node_api.cc b/src/node_api.cc index 2421b9c333dbeb..89a51162d0ff88 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -3614,7 +3614,6 @@ class TsFn: public node::AsyncResource { env(env_), finalize_data(finalize_data_), finalize_cb(finalize_cb_), - idle_running(false), call_js_cb(call_js_cb_ == nullptr ? CallJs : call_js_cb_), handles_closing(false) { ref.Reset(env->isolate, func); @@ -3779,8 +3778,6 @@ class TsFn: public node::AsyncResource { } else { if (uv_idle_stop(&idle) != 0) { idle_stop_failed = true; - } else { - idle_running = false; } } } @@ -3813,14 +3810,12 @@ class TsFn: public node::AsyncResource { } void MaybeStartIdle() { - if (!idle_running) { - if (uv_idle_start(&idle, IdleCb) != 0) { - v8::HandleScope scope(env->isolate); - CallbackScope cb_scope(this); - CHECK(napi_throw_error(env, - "ERR_NAPI_TSFN_START_IDLE_LOOP", - "Failed to start the idle loop") == napi_ok); - } + if (uv_idle_start(&idle, IdleCb) != 0) { + v8::HandleScope scope(env->isolate); + CallbackScope cb_scope(this); + CHECK(napi_throw_error(env, + "ERR_NAPI_TSFN_START_IDLE_LOOP", + "Failed to start the idle loop") == napi_ok); } } @@ -3923,7 +3918,6 @@ class TsFn: public node::AsyncResource { napi_env env; void* finalize_data; napi_finalize finalize_cb; - bool idle_running; napi_threadsafe_function_call_js call_js_cb; bool handles_closing; };