Set minimum concurreny,

fix: call stop() if all tesks are processed
This commit is contained in:
2014-09-05 00:12:49 +05:30
parent ea2de93dbd
commit 63bbba174f
+3 -1
View File
@@ -40,6 +40,7 @@ JobManager.prototype.updateState = function(){
};
JobManager.prototype.setConcurrency = function( newVal ){
if( newVal > 1){
if( newVal > this.tmpPoolLen ){
var tmpPool = this.tmpPool;
var additionalPoolBlocks = Math.ceil( ( newVal - this.tmpPoolLen )/this.workers.length ), i;
@@ -49,6 +50,7 @@ JobManager.prototype.setConcurrency = function( newVal ){
this.tmpPoolLen += additionalPoolBlocks * this.workers.length ;
}
this.concurrency = newVal;
}
};
/*
@@ -73,7 +75,7 @@ JobManager.prototype.$doWork_ = function( cb ){
var self = this;
var task = self.tasks.splice(0, 1)[0];
if( task == undefined ){
if( this.onStopped ){ this.onStopped(); }
this.stop();
}
var worker = self.getFromPool();
this.work( task, worker, function(err){