File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ var lists = {};
45
45
// the main function - creates lists on demand and the watchers associated
46
46
// with them.
47
47
function insert ( item , msecs ) {
48
- item . _idleStart = Date . now ( ) ;
48
+ item . _idleStart = Timer . now ( ) ;
49
49
item . _idleTimeout = msecs ;
50
50
51
51
if ( msecs < 0 ) return ;
@@ -75,7 +75,7 @@ function listOnTimeout() {
75
75
76
76
debug ( 'timeout callback %d' , msecs ) ;
77
77
78
- var now = Date . now ( ) ;
78
+ var now = Timer . now ( ) ;
79
79
debug ( 'now: %s' , now ) ;
80
80
81
81
var first ;
@@ -165,7 +165,7 @@ exports.active = function(item) {
165
165
if ( ! list || L . isEmpty ( list ) ) {
166
166
insert ( item , msecs ) ;
167
167
} else {
168
- item . _idleStart = Date . now ( ) ;
168
+ item . _idleStart = Timer . now ( ) ;
169
169
L . append ( list , item ) ;
170
170
}
171
171
}
@@ -277,7 +277,7 @@ var Timeout = function(after) {
277
277
278
278
Timeout . prototype . unref = function ( ) {
279
279
if ( ! this . _handle ) {
280
- var now = Date . now ( ) ;
280
+ var now = Timer . now ( ) ;
281
281
if ( ! this . _idleStart ) this . _idleStart = now ;
282
282
var delay = this . _idleStart + this . _idleTimeout - now ;
283
283
if ( delay < 0 ) delay = 0 ;
Original file line number Diff line number Diff line change @@ -28,6 +28,8 @@ var stream = require('stream');
28
28
var assert = require ( 'assert' ) . ok ;
29
29
var constants = require ( 'constants' ) ;
30
30
31
+ var Timer = process . binding ( 'timer_wrap' ) . Timer ;
32
+
31
33
var DEFAULT_CIPHERS = 'ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:' + // TLS 1.2
32
34
'RC4:HIGH:!MD5:!aNULL:!EDH' ; // TLS 1.0
33
35
@@ -720,7 +722,7 @@ function onhandshakestart() {
720
722
721
723
var self = this ;
722
724
var ssl = self . ssl ;
723
- var now = Date . now ( ) ;
725
+ var now = Timer . now ( ) ;
724
726
725
727
assert ( now >= ssl . lastHandshakeTime ) ;
726
728
Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ class TimerWrap : public HandleWrap {
51
51
constructor->InstanceTemplate ()->SetInternalFieldCount (1 );
52
52
constructor->SetClassName (String::NewSymbol (" Timer" ));
53
53
54
+ NODE_SET_METHOD (constructor, " now" , Now);
55
+
54
56
NODE_SET_PROTOTYPE_METHOD (constructor, " close" , HandleWrap::Close);
55
57
NODE_SET_PROTOTYPE_METHOD (constructor, " ref" , HandleWrap::Ref);
56
58
NODE_SET_PROTOTYPE_METHOD (constructor, " unref" , HandleWrap::Unref);
@@ -163,6 +165,13 @@ class TimerWrap : public HandleWrap {
163
165
MakeCallback (wrap->object_ , ontimeout_sym, ARRAY_SIZE (argv), argv);
164
166
}
165
167
168
+ static Handle<Value> Now (const Arguments& args) {
169
+ HandleScope scope (node_isolate);
170
+
171
+ double now = static_cast <double >(uv_now (uv_default_loop ()));
172
+ return scope.Close (v8::Number::New (now));
173
+ }
174
+
166
175
uv_timer_t handle_;
167
176
};
168
177
You can’t perform that action at this time.
0 commit comments