| 121 | // Each call holds in-flight until the gate opens, so max concurrency across |
| 122 | // the pool is observable: with size=5 and 5 calls, all 5 should run at once. |
| 123 | const behavior = (m: CallMsg): Action => ({ |
| 124 | wait: (async () => { |
| 125 | active++; maxActive = Math.max(maxActive, active); |
| 126 | await gate; |
| 127 | active--; |
| 128 | return ok(`r${m.id}`); |
| 129 | })(), |
| 130 | }); |
| 131 | const pool = new QueryPool({ root: '/x', size: 5, createWorker: () => new FakeWorker(behavior) }); |
| 132 | const calls = Promise.all(Array.from({ length: 5 }, (_, i) => pool.run('codegraph_search', { i }))); |
| 133 | await sleep(40); // let all workers spawn (cold-start cap → a few generations) + dispatch |