* stop the runner loop if all tasks are finished.
* don't check for tasks.length ; instead check only state variable
This commit is contained in:
2014-09-09 21:06:28 +05:30
parent 4c0af89fbd
commit 3e898725f3
+2 -1
View File
@@ -77,6 +77,7 @@ JobManager.prototype.$doWork_ = function( cb ){
var task = self.tasks.splice(0, 1)[0];
if( task == undefined ){
this.stop();
return;
}
var worker = self.getFromPool();
this.work( task, worker, function(err){
@@ -96,7 +97,7 @@ JobManager.prototype.$doWork_ = function( cb ){
JobManager.prototype.$trigger = function (){
var self = this;
while( this.runningTasks < this.concurrency && this.state == STATE.RUNNING && this.tasks.length ){
while( this.runningTasks < this.concurrency && this.state == STATE.RUNNING ){
this.$doWork_( function(){
self.$trigger();
});