| 193 | } |
| 194 | |
| 195 | flush(): void { |
| 196 | // Empty the queue |
| 197 | this.queue.takeAll(); |
| 198 | |
| 199 | // Remove reference to runing tasks, they will still continue running but the result wont be used |
| 200 | this.runningTasks = []; |
| 201 | |
| 202 | // Set the next task to the index that would be used after flush |
| 203 | this.nextTask = this.nextIndex; |
| 204 | // Clean up out of order tasks |
| 205 | Object.entries(this.outOfOrderTasks).map(([id, task]) => { |
| 206 | // Is this desired behaviour? The other option would be resolving undefined |
| 207 | task.action.reject(new TaskFlushedError(this.name)); |
| 208 | }); |
| 209 | this.outOfOrderTasks = {}; |
| 210 | this.pendingPromise = false; |
| 211 | } |
| 212 | |
| 213 | abort(): void { |
| 214 | this._abort = true; |