Add support for minimum concurrency . SetConcurrency method can not assign value below this value.

It need to be replaced with nonlinear function
This commit is contained in:
2014-09-07 10:12:06 +05:30
parent 63bbba174f
commit bc8c4792e0
+2 -1
View File
@@ -9,6 +9,7 @@ function JobManager(opts){
//opts
this.notifyAt = opts.notifyAt|| 3;
this.concurrency = opts.concurrency || 20;
this.minConcurrency = opts.minConcurrency != null ? opts.minConcurrency : 2;
// state
this.state = STATE.NOT_RUNNING;
@@ -40,7 +41,7 @@ JobManager.prototype.updateState = function(){
};
JobManager.prototype.setConcurrency = function( newVal ){
if( newVal > 1){
if( newVal > this.minConcurrency ){
if( newVal > this.tmpPoolLen ){
var tmpPool = this.tmpPool;
var additionalPoolBlocks = Math.ceil( ( newVal - this.tmpPoolLen )/this.workers.length ), i;