()
| 6976 | } |
| 6977 | |
| 6978 | async maybeStartQueuedTasks(): Promise<void> { |
| 6979 | const existingRun = this.maybeStartQueuedTasksInFlight; |
| 6980 | if (existingRun != null) { |
| 6981 | this.maybeStartQueuedTasksRerunRequested = true; |
| 6982 | await existingRun; |
| 6983 | return; |
| 6984 | } |
| 6985 | |
| 6986 | // A foreground task waiter registers itself in waitForAgentReport's async setup. Yield once so |
| 6987 | // immediate scheduler calls from the same turn see that foreground-awaiting state and avoid a |
| 6988 | // nested-task deadlock at maxParallelAgentTasks=1. |
| 6989 | await Promise.resolve(); |
| 6990 | const existingRunAfterYield = this.maybeStartQueuedTasksInFlight; |
| 6991 | if (existingRunAfterYield != null) { |
| 6992 | this.maybeStartQueuedTasksRerunRequested = true; |
| 6993 | await existingRunAfterYield; |
| 6994 | return; |
| 6995 | } |
| 6996 | |
| 6997 | const run = (async () => { |
| 6998 | do { |
| 6999 | this.maybeStartQueuedTasksRerunRequested = false; |
| 7000 | await this.maybeStartQueuedTasksFromReservations(); |
| 7001 | } while (this.maybeStartQueuedTasksRerunRequested); |
| 7002 | })().finally(() => { |
| 7003 | if (this.maybeStartQueuedTasksInFlight === run) { |
| 7004 | this.maybeStartQueuedTasksInFlight = undefined; |
| 7005 | } |
| 7006 | }); |
| 7007 | this.maybeStartQueuedTasksInFlight = run; |
| 7008 | await run; |
| 7009 | } |
| 7010 | |
| 7011 | private async maybeStartQueuedTasksFromReservations(): Promise<void> { |
| 7012 | const plans: TaskLaunchPlan[] = []; |
no test coverage detected