diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-24 18:03:53 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-24 21:49:35 +0200 |
commit | 0330bdf5195eb77f04c26a09a8bd2088a261fe53 (patch) | |
tree | 2c13f9f1757bca93e83e425a028dcae78549f40e /lib/cluster.js | |
parent | 457d52924152c6f2baf2fddbe76a03bca7bdde7c (diff) | |
download | android-node-v8-0330bdf5195eb77f04c26a09a8bd2088a261fe53.tar.gz android-node-v8-0330bdf5195eb77f04c26a09a8bd2088a261fe53.tar.bz2 android-node-v8-0330bdf5195eb77f04c26a09a8bd2088a261fe53.zip |
lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
Diffstat (limited to 'lib/cluster.js')
-rw-r--r-- | lib/cluster.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/cluster.js b/lib/cluster.js index b5859348e0..650389278c 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -68,7 +68,7 @@ function SharedHandle(key, address, port, addressType, backlog, fd) { else rval = net._createServerHandle(address, port, addressType, fd); - if (typeof rval === 'number') + if (IS_NUMBER(rval)) this.errno = rval; else this.handle = rval; @@ -135,7 +135,7 @@ RoundRobinHandle.prototype.add = function(worker, send) { self.handoff(worker); // In case there are connections pending. } - if (this.server === null) return done(); + if (IS_NULL(this.server)) return done(); // Still busy binding. this.server.once('listening', done); this.server.once('error', function(err) { @@ -166,7 +166,7 @@ RoundRobinHandle.prototype.handoff = function(worker) { return; // Worker is closing (or has closed) the server. } var handle = this.handles.shift(); - if (typeof handle === 'undefined') { + if (IS_UNDEFINED(handle)) { this.free.push(worker); // Add to ready queue again. return; } @@ -225,7 +225,7 @@ function masterInit() { 'rr': SCHED_RR }[process.env.NODE_CLUSTER_SCHED_POLICY]; - if (typeof schedulingPolicy === 'undefined') { + if (IS_UNDEFINED(schedulingPolicy)) { // FIXME Round-robin doesn't perform well on Windows right now due to the // way IOCP is wired up. Bert is going to fix that, eventually. schedulingPolicy = (process.platform === 'win32') ? SCHED_NONE : SCHED_RR; @@ -367,7 +367,7 @@ function masterInit() { message.fd]; var key = args.join(':'); var handle = handles[key]; - if (typeof handle === 'undefined') { + if (IS_UNDEFINED(handle)) { var constructor = RoundRobinHandle; // UDP is exempt from round-robin connection balancing for what should // be obvious reasons: it's connectionless. There is nothing to send to @@ -474,7 +474,7 @@ function workerInit() { delete handles[key]; return close.apply(this, arguments); }; - assert(typeof handles[key] === 'undefined'); + assert(IS_UNDEFINED(handles[key])); handles[key] = handle; cb(handle); } @@ -511,7 +511,7 @@ function workerInit() { // the ack by the master process in which we can still receive handles. // onconnection() below handles that by sending those handles back to // the master. - if (typeof key === 'undefined') return; + if (IS_UNDEFINED(key)) return; send({ act: 'close', key: key }); delete handles[key]; key = undefined; @@ -529,7 +529,7 @@ function workerInit() { if (message.sockname) { handle.getsockname = getsockname; // TCP handles only. } - assert(typeof handles[key] === 'undefined'); + assert(IS_UNDEFINED(handles[key])); handles[key] = handle; cb(handle); } @@ -539,7 +539,7 @@ function workerInit() { function onconnection(message, handle) { var key = message.key; var server = handles[key]; - var accepted = (typeof server !== 'undefined'); + var accepted = !IS_UNDEFINED(server); send({ ack: message.seq, accepted: accepted }); if (accepted) server.onconnection(0, handle); } @@ -585,7 +585,7 @@ function internal(worker, cb) { return function(message, handle) { if (message.cmd !== 'NODE_CLUSTER') return; var fn = cb; - if (typeof message.ack !== 'undefined') { + if (!IS_UNDEFINED(message.ack)) { fn = callbacks[message.ack]; delete callbacks[message.ack]; } |