(promiseGenerator, ...args)
| 654 | } |
| 655 | |
| 656 | async enqueue(promiseGenerator, ...args) { |
| 657 | if (this.status !== TaskStatus.init) { |
| 658 | throw new Error(`Task is in an invalid status ${this.status} to add to queue.`) |
| 659 | } |
| 660 | this._setStatus(TaskStatus.pending) |
| 661 | task_queue.set(this, promiseGenerator) |
| 662 | await eventSource.fireEvent(EVENT_TASK_QUEUED, { task: this }) |
| 663 | await Task.enqueue(promiseGenerator, ...args) |
| 664 | await this.waitUntil({ status: TaskStatus.completed }) |
| 665 | if (this.exception) { |
| 666 | throw this.exception |
| 667 | } |
| 668 | return this.result |
| 669 | } |
| 670 | static async enqueue(promiseGenerator, ...args) { |
| 671 | if (typeof promiseGenerator === "undefined") { |
| 672 | throw new Error("To enqueue a concurrent task, a *Promise Generator is needed but undefined was found.") |
no test coverage detected