mirror of
https://github.com/harish2704/node-job-manager.git
synced 2026-09-10 13:11:08 +00:00
Fix: setConcurrency
This commit is contained in:
+11
-1
@@ -48,6 +48,7 @@ JobManager.prototype.setConcurrency = function( newVal ){
|
|||||||
}
|
}
|
||||||
this.tmpPoolLen += additionalPoolBlocks * this.workers.length ;
|
this.tmpPoolLen += additionalPoolBlocks * this.workers.length ;
|
||||||
}
|
}
|
||||||
|
this.concurrency = newVal;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -70,8 +71,11 @@ JobManager.prototype.getFromPool = function(){
|
|||||||
|
|
||||||
JobManager.prototype.$doWork_ = function( cb ){
|
JobManager.prototype.$doWork_ = function( cb ){
|
||||||
var self = this;
|
var self = this;
|
||||||
var worker = self.getFromPool();
|
|
||||||
var task = self.tasks.splice(0, 1)[0];
|
var task = self.tasks.splice(0, 1)[0];
|
||||||
|
if( task == undefined ){
|
||||||
|
if( this.onStopped ){ this.onStopped(); }
|
||||||
|
}
|
||||||
|
var worker = self.getFromPool();
|
||||||
this.work( task, worker, function(err){
|
this.work( task, worker, function(err){
|
||||||
if(err){
|
if(err){
|
||||||
self.onError(err, task, worker );
|
self.onError(err, task, worker );
|
||||||
@@ -114,6 +118,12 @@ JobManager.prototype.pause = function(){
|
|||||||
this.state = STATE.NOT_RUNNING;
|
this.state = STATE.NOT_RUNNING;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JobManager.prototype.stop = function(){
|
||||||
|
this.state = STATE.NOT_RUNNING;
|
||||||
|
if( this.onStopped ){ this.onStopped(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
JobManager.prototype.resume = function(){
|
JobManager.prototype.resume = function(){
|
||||||
this.start();
|
this.start();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user