var L = require('_linklist');
var assert = require('assert').ok;
+var kOnTimeout = Timer.kOnTimeout | 0;
+
// Timeout values > TIMEOUT_MAX are set to 1.
var TIMEOUT_MAX = 2147483647; // 2^31-1
lists[msecs] = list;
list.msecs = msecs;
- list.ontimeout = listOnTimeout;
+ list[kOnTimeout] = listOnTimeout;
}
L.append(list, item);
} finally {
if (threw) {
process.nextTick(function() {
- list.ontimeout();
+ list[kOnTimeout]();
});
}
}
exports.clearTimeout = function(timer) {
- if (timer && (timer.ontimeout || timer._onTimeout)) {
- timer.ontimeout = timer._onTimeout = null;
+ if (timer && (timer[kOnTimeout] || timer._onTimeout)) {
+ timer[kOnTimeout] = timer._onTimeout = null;
if (timer instanceof Timeout) {
timer.close(); // for after === 0
} else {
if (delay < 0) delay = 0;
exports.unenroll(this);
this._handle = new Timer();
- this._handle.ontimeout = this._onTimeout;
+ this._handle[kOnTimeout] = this._onTimeout;
this._handle.start(delay, 0);
this._handle.domain = this.domain;
this._handle.unref();
Timeout.prototype.close = function() {
this._onTimeout = null;
if (this._handle) {
- this._handle.ontimeout = null;
+ this._handle[kOnTimeout] = null;
this._handle.close();
} else {
exports.unenroll(this);
unrefTimer = new Timer();
unrefTimer.unref();
unrefTimer.when = -1;
- unrefTimer.ontimeout = unrefTimeout;
+ unrefTimer[kOnTimeout] = unrefTimeout;
}
var now = Timer.now();
#include "node.h"
#include "handle_wrap.h"
+#include <stdint.h>
+
namespace node {
using v8::Function;
using v8::String;
using v8::Value;
-static Cached<String> ontimeout_sym;
+const uint32_t kOnTimeout = 0;
class TimerWrap : public HandleWrap {
public:
Local<FunctionTemplate> constructor = FunctionTemplate::New(New);
constructor->InstanceTemplate()->SetInternalFieldCount(1);
constructor->SetClassName(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"));
+ constructor->Set(FIXED_ONE_BYTE_STRING(node_isolate, "kOnTimeout"),
+ Integer::New(kOnTimeout, node_isolate));
NODE_SET_METHOD(constructor, "now", Now);
NODE_SET_PROTOTYPE_METHOD(constructor, "getRepeat", GetRepeat);
NODE_SET_PROTOTYPE_METHOD(constructor, "again", Again);
- ontimeout_sym = FIXED_ONE_BYTE_STRING(node_isolate, "ontimeout");
-
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Timer"),
constructor->GetFunction());
}
assert(wrap);
Local<Value> argv[1] = { Integer::New(status, node_isolate) };
- MakeCallback(wrap->object(), ontimeout_sym, ARRAY_SIZE(argv), argv);
+ MakeCallback(wrap->object(), kOnTimeout, ARRAY_SIZE(argv), argv);
}
static void Now(const FunctionCallbackInfo<Value>& args) {