node-worker-pool
Advanced tools
Comparing version
{ | ||
"name": "node-worker-pool", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "q": "~0.9.7" |
@@ -19,2 +19,3 @@ "use strict"; | ||
//this._workerErrorOutput = {}; | ||
this._shutdownDeferred = null; | ||
this._workerIdToMsgId = {}; | ||
@@ -56,2 +57,4 @@ this._workerOutput = []; | ||
WorkerPool.prototype.shutDown = function() { | ||
this._shutdownDeferred = Q.defer(); | ||
var shutdownPromise = this._shutdownDeferred.promise; | ||
if (this._availWorkerIds.length !== this._workers.length) { | ||
@@ -61,3 +64,6 @@ this._isShutdown = true; | ||
this._destroyAllWorkers(); | ||
this._shutdownDeferred.resolve(); | ||
this._shutdownDeferred = null; | ||
} | ||
return shutdownPromise; | ||
} | ||
@@ -88,2 +94,3 @@ | ||
worker.stdin.end(); | ||
worker.kill(); | ||
}); | ||
@@ -126,3 +133,3 @@ }; | ||
); | ||
if (responses.length === 1) { | ||
@@ -151,5 +158,7 @@ var msgId = this._workerIdToMsgId[workerId]; | ||
this._sendMsgToAvailWorker(msgId); | ||
} else if (this._isShutdown && | ||
} else if (this._isShutdown && | ||
this._availWorkerIds.length === this._workers.length) { | ||
this._destroyAllWorkers(); | ||
this._shutdownDeferred.resolve(); | ||
this._shutdownDeferred = null; | ||
this._isShutdown = false; | ||
@@ -156,0 +165,0 @@ } |
8474
3.91%251
3.72%