Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
docs: grammar and spelling on lib/cluster.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott authored and bnoordhuis committed Apr 5, 2012
1 parent b6d6a54 commit d73b257
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions lib/cluster.js
Expand Up @@ -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]);
Expand All @@ -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;

Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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);
}
Expand All @@ -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);

Expand All @@ -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

This comment has been minimized.

Copy link
@mscdex

mscdex Apr 6, 2012

s/Send/Call/

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
Expand All @@ -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;
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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();

Expand Down Expand Up @@ -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);
};

Expand All @@ -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);
});
Expand All @@ -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() {
Expand All @@ -414,16 +414,16 @@ 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.
self.process.disconnect();
});

// 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();
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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();
};

Expand All @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit d73b257

Please sign in to comment.