Permalink
Browse files

change the prameter of the spawn call around.

  • Loading branch information...
1 parent acbd9e3 commit e3258fbd389fb43cbb2e963feaf22b875c02d942 Joachim Kainz committed Oct 2, 2011
Showing with 13 additions and 16 deletions.
  1. +4 −4 examples/master.js
  2. +9 −12 lib/backgrounder.js
View
@@ -2,7 +2,10 @@ var backgrounder = require("../lib/backgrounder");
//
// Spawn the worker in a backround proccess
//
-var worker = backgrounder.spawn(__dirname + "/worker.js", function(worker){
+var worker = backgrounder.spawn(__dirname + "/worker.js", {
+ "primaryDirective": "don't interfere",
+ "overdrive": true
+ }, function(worker){
//
// For this demo, let's just print any message we are receiving from the worker
//
@@ -48,7 +51,4 @@ var worker = backgrounder.spawn(__dirname + "/worker.js", function(worker){
console.error("Master: unexpected idle message ", counter, message);
}
});
-}, {
- "primaryDirective": "don't interfere",
- "overdrive": true
});
View
@@ -123,21 +123,18 @@ Child.prototype.terminate = function() {
});
};
// export the spwan method, which creates the client object.
-module.exports.spawn = function(module, callback, config) {
+module.exports.spawn = function(module, config, callback) {
var child = new Child(module);
if (!config) {
- if (callback) {
- callback(child);
- }
- }
- else {
- sendMessage(child, {
- "type": "config",
- "content": config
- }, function(){
- callback(child);
- });
+ return child;
}
+ sendMessage(child, {
+ "type": "config",
+ "content": config
+ }, function(){
+ callback(child);
+ });
+
return child;
};

0 comments on commit e3258fb

Please sign in to comment.