lib/application.js
function() {
        var args = [].slice.call(arguments, 0);
        var workerMessage, done = 0;
        var workerKeys = Object.keys(cluster.workers);
        var nextWorker = function() {
          if (workerKeys.length) {
            done++;
            cluster.workers[workerKeys.shift()].send(taskMessage.concat([args]));
          } else {
            app.log("Executed [%s] on %d workers", id, done);
            app.removeListener('worker_message', workerMessage);
          }
        }
        app.on('worker_message', workerMessage = function(msg) {
          if (isMessageForMe(msg) && msg[3] === 'done') {
            nextWorker()
          }
        });
        nextWorker();
      }
function() {
        var args = [].slice.call(arguments, 0);
        var workerMessage, done = 0;
        var workerKeys = Object.keys(cluster.workers);
        var nextWorker = function() {
          if (workerKeys.length) {
            done++;
            cluster.workers[workerKeys.shift()].send(taskMessage.concat([args]));
          } else {
            app.log("Executed [%s] on %d workers", id, done);
            app.removeListener('worker_message', workerMessage);
          }
        }
        app.on('worker_message', workerMessage = function(msg) {
          if (isMessageForMe(msg) && msg[3] === 'done') {
            nextWorker()
          }
        });
        nextWorker();
      }
function ( ) { var args = [ ] . slice . call ( arguments , 0 ) ; var workerMessage , done = 0 ; var workerKeys = Object . keys ( cluster . workers ) ; var nextWorker = function ( ) { if ( workerKeys . length ) { done ++ ; cluster . workers [ workerKeys . shift ( ) ] . send ( taskMessage . concat ( [ args ] ) ) ; } else { app . log ( "Executed [%s] on %d workers" , id , done ) ; app . removeListener ( 'worker_message' , workerMessage ) ; } } app . on ( 'worker_message' , workerMessage = function ( msg ) { if ( isMessageForMe ( msg ) && msg [ 3 ] === 'done' ) { nextWorker ( ) } } ) ; nextWorker ( ) ; }
Master 1. Listen for worker messages and send task to all workers on receive Sends a message to all workers to run the task
Master 1 . Listen for worker messages and send task to all workers on receive Sends a message to all workers to run the task