File tree Expand file tree Collapse file tree 3 files changed +19
-14
lines changed
Expand file tree Collapse file tree 3 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,16 @@ namespace node {
1111using v8::Context;
1212using v8::FunctionTemplate;
1313using v8::HandleScope;
14+ using v8::Integer;
1415using v8::Isolate;
1516using v8::Local;
1617using v8::Message;
18+ using v8::Number;
1719using v8::Private;
1820using v8::StackFrame;
1921using v8::StackTrace;
2022using v8::String;
23+ using v8::Value;
2124
2225IsolateData::IsolateData (Isolate* isolate,
2326 uv_loop_t * event_loop,
@@ -362,6 +365,18 @@ void Environment::ToggleImmediateRef(bool ref) {
362365}
363366
364367
368+ Local<Value> Environment::GetNow () {
369+ uv_update_time (event_loop ());
370+ uint64_t now = uv_now (event_loop ());
371+ CHECK_GE (now, timer_base ());
372+ now -= timer_base ();
373+ if (now <= 0xffffffff )
374+ return Integer::New (isolate (), static_cast <uint32_t >(now));
375+ else
376+ return Number::New (isolate (), static_cast <double >(now));
377+ }
378+
379+
365380void CollectExceptionInfo (Environment* env,
366381 v8::Local<v8::Object> obj,
367382 int errorno,
Original file line number Diff line number Diff line change @@ -735,6 +735,8 @@ class Environment {
735735
736736 static inline Environment* ForAsyncHooks (AsyncHooks* hooks);
737737
738+ v8::Local<v8::Value> GetNow ();
739+
738740 private:
739741 inline void CreateImmediate (native_immediate_callback cb,
740742 void * data,
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ using v8::FunctionTemplate;
3737using v8::HandleScope;
3838using v8::Integer;
3939using v8::Local;
40- using v8::Number;
4140using v8::Object;
4241using v8::String;
4342using v8::Value;
@@ -142,7 +141,7 @@ class TimerWrap : public HandleWrap {
142141 Local<Value> ret;
143142 Local<Value> args[1 ];
144143 do {
145- args[0 ] = GetNow (env );
144+ args[0 ] = env-> GetNow ();
146145 ret = wrap->MakeCallback (kOnTimeout , 1 , args).ToLocalChecked ();
147146 } while (ret->IsUndefined () &&
148147 !env->tick_info ()->has_thrown () &&
@@ -153,18 +152,7 @@ class TimerWrap : public HandleWrap {
153152
154153 static void Now (const FunctionCallbackInfo<Value>& args) {
155154 Environment* env = Environment::GetCurrent (args);
156- args.GetReturnValue ().Set (GetNow (env));
157- }
158-
159- static Local<Value> GetNow (Environment* env) {
160- uv_update_time (env->event_loop ());
161- uint64_t now = uv_now (env->event_loop ());
162- CHECK (now >= env->timer_base ());
163- now -= env->timer_base ();
164- if (now <= 0xfffffff )
165- return Integer::New (env->isolate (), static_cast <uint32_t >(now));
166- else
167- return Number::New (env->isolate (), static_cast <double >(now));
155+ args.GetReturnValue ().Set (env->GetNow ());
168156 }
169157
170158 uv_timer_t handle_;
You can’t perform that action at this time.
0 commit comments