* Returns the ready worker with the fewest active executions that still * has capacity, or null if none available.
()
| 1040 | * has capacity, or null if none available. |
| 1041 | */ |
| 1042 | function selectWorker(): WorkerInfo | null { |
| 1043 | let best: WorkerInfo | null = null |
| 1044 | for (const w of workers.values()) { |
| 1045 | if (!w.ready) continue |
| 1046 | if (w.retiring) continue |
| 1047 | if (w.activeExecutions >= MAX_PER_WORKER) continue |
| 1048 | if (!best || w.activeExecutions < best.activeExecutions) { |
| 1049 | best = w |
| 1050 | } |
| 1051 | } |
| 1052 | return best |
| 1053 | } |
| 1054 | |
| 1055 | /** |
| 1056 | * Tries to get an existing worker with capacity, or spawns a new one if the |
no outgoing calls
no test coverage detected