Fix: Don't call onStopped immediatly on stop(). Instead call onStopped() after finishing all running tasks

This commit is contained in:
2014-09-12 21:45:38 +05:30
parent 3e898725f3
commit 971f97e5f5
+3 -1
View File
@@ -90,6 +90,9 @@ JobManager.prototype.$doWork_ = function( cb ){
}
}
cb();
if( self.state == STATE.NOT_RUNNING ){
if( ( self.runningTasks == 1 ) && self.onStopped ) { self.onStopped(); }
}
self.returnToPool( worker );
});
};
@@ -124,7 +127,6 @@ JobManager.prototype.pause = function(){
JobManager.prototype.stop = function(){
this.state = STATE.NOT_RUNNING;
if( this.onStopped ){ this.onStopped(); }
};