|
@ -40,6 +40,7 @@ JobManager.prototype.updateState = function(){ |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
JobManager.prototype.setConcurrency = function( newVal ){ |
|
|
JobManager.prototype.setConcurrency = function( newVal ){ |
|
|
|
|
|
if( newVal > 1){ |
|
|
if( newVal > this.tmpPoolLen ){ |
|
|
if( newVal > this.tmpPoolLen ){ |
|
|
var tmpPool = this.tmpPool; |
|
|
var tmpPool = this.tmpPool; |
|
|
var additionalPoolBlocks = Math.ceil( ( newVal - this.tmpPoolLen )/this.workers.length ), i; |
|
|
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.tmpPoolLen += additionalPoolBlocks * this.workers.length ; |
|
|
} |
|
|
} |
|
|
this.concurrency = newVal; |
|
|
this.concurrency = newVal; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
@ -73,7 +75,7 @@ JobManager.prototype.$doWork_ = function( cb ){ |
|
|
var self = this; |
|
|
var self = this; |
|
|
var task = self.tasks.splice(0, 1)[0]; |
|
|
var task = self.tasks.splice(0, 1)[0]; |
|
|
if( task == undefined ){ |
|
|
if( task == undefined ){ |
|
|
if( this.onStopped ){ this.onStopped(); } |
|
|
|
|
|
|
|
|
this.stop(); |
|
|
} |
|
|
} |
|
|
var worker = self.getFromPool(); |
|
|
var worker = self.getFromPool(); |
|
|
this.work( task, worker, function(err){ |
|
|
this.work( task, worker, function(err){ |
|
|