mirror of
https://github.com/harish2704/node-job-manager.git
synced 2026-09-10 13:11:08 +00:00
Fix:
* 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:
+2
-1
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user