var cluster = require("cluster");
var path = require("path");
var Message = require(path.join(__dirname, 'message'));
var Shared = require(path.join(__dirname, 'shared'));


var Worker = function(options){
  // The runtime context, from here, is from within the master process.

  var options = options || {};
  var priv = {
    onMessageHandler: options['onMessage'],
  };

  var attributes = {};
  var env = {
    'swap': options['shared']['swap'],
  };
  attributes['process'] = cluster.fork(env);
  attributes['process'].on('message', priv.onMessageHandler);

  return Object.assign(attributes, {

    send: function(msg){
      this.process.send(msg); // send to our worker process
    },

  });

};


// The runtime context, from here, is from within a worker process..
if(require.main === module){
  // our file was called directly rather than req'd.
  //console.log('worker #' + process.pid, 'loaded!');
  var shared = new Shared({
    'swap': process.env.swap
  });

  process.on('message', function(msg){
    var message = msg['payload'];
    //console.log('worker #' + process.pid, 'rec\'d message from master:', msg);
    switch(message['type']){
      case 'action':
        //console.log('running action:', message['id']);
        shared.get(message['id']).apply(this, message['arguments']);
        break;
      case 'ping':
        // do nothing?
        break;

    }
    if(msg['type'] == 'action'){
    }

  });

  //var msg = new Message();
  //msg.setPayload('ping', Shared.ping.worker_message);
  //process.send(msg);
} else {
  // our file is loaded in a require(...) statement.
  module.exports = Worker;
}

@@ -1225,24 +1225,83 @@
 sage%5B'id'%5D);
+%0A%0A        var cxt = shared %7C%7C message%5B'arguments'%5D %7C%7C this;
 %0A        sha
@@ -1329,20 +1329,19 @@
 ).apply(
-this
+cxt
 , messag

allow for context in async execs