|
@@ -24,7 +24,18 @@ var TaskQueue = Class.extend(EmitterMixin, {
|
|
|
|
|
|
|
|
resume: function() {
|
|
resume: function() {
|
|
|
this.isPaused = false;
|
|
this.isPaused = false;
|
|
|
- this.tryStart();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.isRunning && !this.q.length) {
|
|
|
|
|
+ this.trigger('idle'); // TODO: write tests
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ this.tryStart();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ getIsIdle: function() {
|
|
|
|
|
+ return !this.isRunning && !this.isPaused;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
@@ -63,7 +74,13 @@ var TaskQueue = Class.extend(EmitterMixin, {
|
|
|
|
|
|
|
|
this.trigger('stop'); // not really a 'stop' ... more of a 'drained'
|
|
this.trigger('stop'); // not really a 'stop' ... more of a 'drained'
|
|
|
this.isRunning = false;
|
|
this.isRunning = false;
|
|
|
- this.tryStart(); // if 'stop' handler added more tasks.... TODO: write test for this
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.isPaused && !this.q.length) {
|
|
|
|
|
+ this.trigger('idle'); // TODO: write tests
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ this.tryStart(); // if 'stop' handler added more tasks.... TODO: write test for this
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
|