summaryrefslogtreecommitdiff
path: root/lib/cluster.js
diff options
context:
space:
mode:
authorZachary Scott <zachary@zacharyscott.net>2012-04-01 22:55:09 -0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-04-06 01:44:03 +0200
commitd73b257d6543606e23361a0cd8a41e09591f4312 (patch)
treebaf50a12b336634cc442e2ec9e05bd7fa992ac8d /lib/cluster.js
parentb6d6a54f8057d0adad13d4bcc11eb3f443079ddc (diff)
downloadandroid-node-v8-d73b257d6543606e23361a0cd8a41e09591f4312.tar.gz
android-node-v8-d73b257d6543606e23361a0cd8a41e09591f4312.tar.bz2
android-node-v8-d73b257d6543606e23361a0cd8a41e09591f4312.zip
docs: grammar and spelling on lib/cluster.js
Diffstat (limited to 'lib/cluster.js')
-rw-r--r--lib/cluster.js60
1 files changed, 30 insertions, 30 deletions
diff --git a/lib/cluster.js b/lib/cluster.js
index dfd13cd926..504c399ef7 100644
--- a/lib/cluster.js
+++ b/lib/cluster.js
@@ -61,15 +61,15 @@ cluster.isMaster = ! cluster.isWorker;
// The worker object is only used in a worker
cluster.worker = cluster.isWorker ? {} : null;
-// The workers array is oly used in the naster
+// The workers array is only used in the master
cluster.workers = cluster.isMaster ? {} : null;
// Settings object
var settings = cluster.settings = {};
-// Simple function there call a function on each worker
+// Simple function to call a function on each worker
function eachWorker(cb) {
- // Go througe all workers
+ // Go through all workers
for (var id in cluster.workers) {
if (cluster.workers.hasOwnProperty(id)) {
cb(cluster.workers[id]);
@@ -94,7 +94,7 @@ cluster.setupMaster = function(options) {
// This can only be called from the master.
assert(cluster.isMaster);
- // Don't allow this function to run more that once
+ // Don't allow this function to run more than once
if (masterStarted) return;
masterStarted = true;
@@ -121,7 +121,7 @@ function isInternalMessage(message) {
message.cmd.indexOf(INTERNAL_PREFIX) === 0);
}
-// Modyfi message object to be internal
+// Modify message object to be internal
function internalMessage(inMessage) {
var outMessage = util._extend({}, inMessage);
@@ -131,10 +131,10 @@ function internalMessage(inMessage) {
return outMessage;
}
-// Handle callback messges
+// Handle callback messages
function handleResponse(outMessage, outHandle, inMessage, inHandle, worker) {
- // The message there will be send
+ // The message there will be sent
var message = internalMessage(outMessage);
// callback id - will be undefined if not set
@@ -146,7 +146,7 @@ function handleResponse(outMessage, outHandle, inMessage, inHandle, worker) {
delete queryCallbacks[inMessage._queryEcho];
}
- // Send if outWrap do contain something useful
+ // Send if outWrap contains something useful
if (!(outMessage === undefined && message._queryEcho === undefined)) {
sendInternalMessage(worker, message, outHandle);
}
@@ -156,7 +156,7 @@ function handleResponse(outMessage, outHandle, inMessage, inHandle, worker) {
var messageHandler = {};
function handleMessage(worker, inMessage, inHandle) {
- //Remove internal prefix
+ // Remove internal prefix
var message = util._extend({}, inMessage);
message.cmd = inMessage.cmd.substr(INTERNAL_PREFIX.length);
@@ -166,18 +166,18 @@ function handleMessage(worker, inMessage, inHandle) {
handleResponse(outMessage, outHandler, inMessage, inHandle, worker);
}
- // Run handler if it exist
+ // Run handler if it exists
if (messageHandler[message.cmd]) {
messageHandler[message.cmd](message, worker, respond);
}
- // Send respond if it wasn't done
+ // Send respond if it hasn't been called yet
if (respondUsed === false) {
respond();
}
}
-// Messages to the master will be handled using this methods
+// Messages to the master will be handled using these methods
if (cluster.isMaster) {
// Handle online messages from workers
@@ -188,11 +188,11 @@ if (cluster.isMaster) {
cluster.emit('online', worker);
};
- // Handle queryServer messages form workers
+ // Handle queryServer messages from workers
messageHandler.queryServer = function(message, worker, send) {
- // This sequence of infomation is unique to the connection but not
- // to the worker
+ // This sequence of information is unique to the connection
+ // but not to the worker
var args = [message.address, message.port, message.addressType];
var key = args.join(':');
var handler;
@@ -212,7 +212,7 @@ if (cluster.isMaster) {
worker.state = 'listening';
- // Emit listining, now that we know the worker is listning
+ // Emit listening, now that we know the worker is listening
worker.emit('listening', worker, {
address: message.address,
port: message.port,
@@ -232,7 +232,7 @@ if (cluster.isMaster) {
}
-// Messages to a worker will be handled using this methods
+// Messages to a worker will be handled using these methods
else if (cluster.isWorker) {
// Handle worker.disconnect from master
@@ -246,7 +246,7 @@ function toDecInt(value) {
return isNaN(value) ? null : value;
}
-// Create a worker object, there works both for master and worker
+// Create a worker object, that works both for master and worker
function Worker(customEnv) {
if (!(this instanceof Worker)) return new Worker();
@@ -353,7 +353,7 @@ function sendInternalMessage(worker, message/*, handler, callback*/) {
// Send message to worker or master
Worker.prototype.send = function() {
- //You could also just use process.send in a worker
+ // You could also just use process.send in a worker
this.process.send.apply(this.process, arguments);
};
@@ -379,7 +379,7 @@ Worker.prototype.destroy = function() {
// Channel is open
if (this.process.connected) {
- // Inform master that is is suicide and then kill
+ // Inform master to suicide and then kill
sendInternalMessage(this, {cmd: 'suicide'}, function() {
process.exit(0);
});
@@ -394,8 +394,8 @@ Worker.prototype.destroy = function() {
}
};
-// The .disconnect function will close all server and then disconnect
-// the IPC channel.
+// The .disconnect function will close all servers
+// and then disconnect the IPC channel.
if (cluster.isMaster) {
// Used in master
Worker.prototype.disconnect = function() {
@@ -414,7 +414,7 @@ if (cluster.isMaster) {
// keep track of open servers
var servers = Object.keys(serverListeners).length;
var progress = new ProgressTracker(servers, function() {
- // there are no more servers open so we will close the IPC channel.
+ // There are no more servers open so we will close the IPC channel.
// Closing the IPC channel will emit a disconnect event
// in both master and worker on the process object.
// This event will be handled by prepareExit.
@@ -422,8 +422,8 @@ if (cluster.isMaster) {
});
// depending on where this function was called from (master or worker)
- // the suicide state has allready been set.
- // But it dosn't really matter if we set it again.
+ // The suicide state has already been set,
+ // but it doesn't really matter if we set it again.
sendInternalMessage(this, {cmd: 'suicide'}, function() {
// in case there are no servers
progress.check();
@@ -433,7 +433,7 @@ if (cluster.isMaster) {
for (var key in serverListeners) {
server = serverListeners[key];
- // in case the server is closed we wont close it again
+ // in case the server is closed we won't close it again
if (server._handle === null) {
progress.done();
continue;
@@ -452,7 +452,7 @@ cluster.fork = function(env) {
// This can only be called from the master.
assert(cluster.isMaster);
- // Make sure that the master has been initalized
+ // Make sure that the master has been initialized
cluster.setupMaster();
return (new cluster.Worker(env));
@@ -481,7 +481,7 @@ cluster.disconnect = function(callback) {
worker.disconnect();
});
- // in case there wasn't any workers
+ // in case there weren't any workers
progress.check();
};
@@ -491,8 +491,8 @@ cluster._setupWorker = function() {
// Get worker class
var worker = cluster.worker = new Worker();
- // when the worker is disconnected from parent accidentally
// we will terminate the worker
+ // when the worker is disconnected from the parent accidentally
process.once('disconnect', function() {
if (worker.suicide !== true) {
process.exit(0);
@@ -532,7 +532,7 @@ cluster._getServer = function(tcpSelf, address, port, addressType, cb) {
addressType: addressType
};
- // The callback will be stored until the master has responed
+ // The callback will be stored until the master has responded
sendInternalMessage(cluster.worker, message, function(msg, handle) {
cb(handle);
});