Browse Source

Fix:

* stop the runner loop if all tasks are finished.
* don't check for tasks.length ; instead check only state variable
master
Harish.K 11 years ago
parent
commit
3e898725f3
  1. 3
      src/JobManager.js

3
src/JobManager.js

@ -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();
});

Loading…
Cancel
Save