diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-05-05 20:50:21 +0300 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-05-22 22:26:12 +0300 |
commit | 23a56e0c28cd828ef0cabb05b30e03cc8cb57dd5 (patch) | |
tree | c389f61071481a949bcea2d78bffb687ec138221 /src/timer_wrap.cc | |
parent | 6f6f7f749bd6847278836832542116f371ab3aa6 (diff) |
timers: use only a single TimerWrap instance
Hang all timer lists off a single TimerWrap and use the PriorityQueue
to manage expiration priorities. This makes the Timers code clearer,
consumes significantly less resources and improves performance.
PR-URL: https://github.com/nodejs/node/pull/20555
Fixes: https://github.com/nodejs/node/issues/16105
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r-- | src/timer_wrap.cc | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index 88377a3e1b8..1a5a22c25ee 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -62,7 +62,6 @@ class TimerWrap : public HandleWrap { env->SetProtoMethod(constructor, "hasRef", HandleWrap::HasRef); env->SetProtoMethod(constructor, "start", Start); - env->SetProtoMethod(constructor, "stop", Stop); target->Set(timerString, constructor->GetFunction()); @@ -125,32 +124,17 @@ class TimerWrap : public HandleWrap { args.GetReturnValue().Set(err); } - static void Stop(const FunctionCallbackInfo<Value>& args) { - TimerWrap* wrap; - ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); - - CHECK(HandleWrap::IsAlive(wrap)); - - int err = uv_timer_stop(&wrap->handle_); - args.GetReturnValue().Set(err); - } - static void OnTimeout(uv_timer_t* handle) { TimerWrap* wrap = static_cast<TimerWrap*>(handle->data); Environment* env = wrap->env(); HandleScope handle_scope(env->isolate()); Context::Scope context_scope(env->context()); Local<Value> ret; - Local<Value> args[1]; + Local<Value> args[] = { env->GetNow() }; do { - args[0] = env->GetNow(); ret = wrap->MakeCallback(env->timers_callback_function(), 1, args) .ToLocalChecked(); - } while (ret->IsUndefined() && - !env->tick_info()->has_thrown() && - wrap->object()->Get(env->context(), - env->owner_string()).ToLocalChecked() - ->IsUndefined()); + } while (ret->IsUndefined() && !env->tick_info()->has_thrown()); } static void Now(const FunctionCallbackInfo<Value>& args) { |