MCPcopy Index your code
hub / github.com/simstudioai/sim / selectWorker

Function selectWorker

apps/sim/lib/execution/isolated-vm.ts:1042–1053  ·  view source on GitHub ↗

* Returns the ready worker with the fewest active executions that still * has capacity, or null if none available.

()

Source from the content-addressed store, hash-verified

1040 * has capacity, or null if none available.
1041 */
1042function 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

Callers 2

acquireWorkerFunction · 0.85
drainQueueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected