Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

change the prameter of the spawn call around.

  • Loading branch information...
commit e3258fbd389fb43cbb2e963feaf22b875c02d942 1 parent acbd9e3
Joachim Kainz authored

Showing 2 changed files with 13 additions and 16 deletions. Show diff stats Hide diff stats

  1. +4 4 examples/master.js
  2. +9 12 lib/backgrounder.js
8 examples/master.js
@@ -2,7 +2,10 @@ var backgrounder = require("../lib/backgrounder");
2 2 //
3 3 // Spawn the worker in a backround proccess
4 4 //
5   -var worker = backgrounder.spawn(__dirname + "/worker.js", function(worker){
  5 +var worker = backgrounder.spawn(__dirname + "/worker.js", {
  6 + "primaryDirective": "don't interfere",
  7 + "overdrive": true
  8 + }, function(worker){
6 9 //
7 10 // For this demo, let's just print any message we are receiving from the worker
8 11 //
@@ -48,7 +51,4 @@ var worker = backgrounder.spawn(__dirname + "/worker.js", function(worker){
48 51 console.error("Master: unexpected idle message ", counter, message);
49 52 }
50 53 });
51   -}, {
52   - "primaryDirective": "don't interfere",
53   - "overdrive": true
54 54 });
21 lib/backgrounder.js
@@ -123,21 +123,18 @@ Child.prototype.terminate = function() {
123 123 });
124 124 };
125 125 // export the spwan method, which creates the client object.
126   -module.exports.spawn = function(module, callback, config) {
  126 +module.exports.spawn = function(module, config, callback) {
127 127 var child = new Child(module);
128 128
129 129 if (!config) {
130   - if (callback) {
131   - callback(child);
132   - }
133   - }
134   - else {
135   - sendMessage(child, {
136   - "type": "config",
137   - "content": config
138   - }, function(){
139   - callback(child);
140   - });
  130 + return child;
141 131 }
  132 + sendMessage(child, {
  133 + "type": "config",
  134 + "content": config
  135 + }, function(){
  136 + callback(child);
  137 + });
  138 +
142 139 return child;
143 140 };

0 comments on commit e3258fb

Please sign in to comment.
Something went wrong with that request. Please try again.