* Add a task to the end of the queue. Processing starts automatically.
(task: Task)
| 24 | * Add a task to the end of the queue. Processing starts automatically. |
| 25 | */ |
| 26 | enqueue(task: Task): void { |
| 27 | if (this.stopped) { |
| 28 | return; |
| 29 | } |
| 30 | this.tail = this.tail.then(() => { |
| 31 | if (this.stopped) { |
| 32 | return; |
| 33 | } |
| 34 | return task().catch(err => { |
| 35 | console.warn('[sync-queue] Task error:', err); |
| 36 | }); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns a promise that resolves once all currently-enqueued tasks (including |
no outgoing calls
no test coverage detected