Skip to content

@aphyr /gist:3200829
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP
Node.js message passing test
var cluster = require('cluster');
var m = 10000000;
function bounce(msg, out) {
if (msg < m) {
out.send(msg + 1);
return null;
} else {
console.log("Finished with", msg);
out.disconnect();
return msg;
}
}
if(cluster.isMaster) {
var worker = cluster.fork();
worker.on('message', function(msg) {
bounce(msg, worker);
});
worker.send(1);
} else {
process.on('message', function(msg) {
bounce(msg, process);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.