diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2018-02-04 19:48:21 +0300 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-02-07 20:21:41 +0300 |
commit | 1573e4563a0d3f6c08a1dd3ab3d161bece532db5 (patch) | |
tree | 0962ff7697c62bccd291e361e276a13e4b93c78e /src/timer_wrap.cc | |
parent | d0e4d4e0a1ffd665f24ecd2ae91445adbc2b011d (diff) |
src: move GetNow to Environment
PR-URL: https://github.com/nodejs/node/pull/18562
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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 | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc index f1b423d3669..441974ae77b 100644 --- a/src/timer_wrap.cc +++ b/src/timer_wrap.cc @@ -37,7 +37,6 @@ using v8::FunctionTemplate; using v8::HandleScope; using v8::Integer; using v8::Local; -using v8::Number; using v8::Object; using v8::String; using v8::Value; @@ -142,7 +141,7 @@ class TimerWrap : public HandleWrap { Local<Value> ret; Local<Value> args[1]; do { - args[0] = GetNow(env); + args[0] = env->GetNow(); ret = wrap->MakeCallback(kOnTimeout, 1, args).ToLocalChecked(); } while (ret->IsUndefined() && !env->tick_info()->has_thrown() && @@ -153,18 +152,7 @@ class TimerWrap : public HandleWrap { static void Now(const FunctionCallbackInfo<Value>& args) { Environment* env = Environment::GetCurrent(args); - args.GetReturnValue().Set(GetNow(env)); - } - - static Local<Value> GetNow(Environment* env) { - uv_update_time(env->event_loop()); - uint64_t now = uv_now(env->event_loop()); - CHECK(now >= env->timer_base()); - now -= env->timer_base(); - if (now <= 0xfffffff) - return Integer::New(env->isolate(), static_cast<uint32_t>(now)); - else - return Number::New(env->isolate(), static_cast<double>(now)); + args.GetReturnValue().Set(env->GetNow()); } uv_timer_t handle_; |