(workerId: number)
| 872 | } |
| 873 | |
| 874 | function resetWorkerIdleTimeout(workerId: number) { |
| 875 | const workerInfo = workers.get(workerId) |
| 876 | if (!workerInfo) return |
| 877 | |
| 878 | if (workerInfo.idleTimeout) { |
| 879 | clearTimeout(workerInfo.idleTimeout) |
| 880 | workerInfo.idleTimeout = null |
| 881 | } |
| 882 | |
| 883 | if (workerInfo.activeExecutions === 0) { |
| 884 | workerInfo.idleTimeout = setTimeout(() => { |
| 885 | const w = workers.get(workerId) |
| 886 | if (w && w.activeExecutions === 0) { |
| 887 | cleanupWorker(workerId) |
| 888 | } |
| 889 | }, WORKER_IDLE_TIMEOUT_MS) |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | function spawnWorker(): Promise<WorkerInfo> { |
| 894 | const workerId = nextWorkerId++ |
no test coverage detected