Get the current number of workers in the pool.
The number of active workers
Dispose of the worker pool, terminating all workers.
This method is called automatically when using the using syntax.
For manual cleanup, use terminate instead.
InternalGet the next request ID for this pool.
The next request ID
Check if the pool has reached its maximum capacity.
True if the pool is at maximum capacity, false otherwise
This method is useful for implementing early rejection of requests when the worker pool is saturated, preventing resource exhaustion.
import { Hono } from 'hono';
import { ReusableWorkerPool } from 'web-csv-toolbox';
const pool = new ReusableWorkerPool({ maxWorkers: 4 });
app.post('/validate-csv', async (c) => {
// Early rejection if pool is saturated
if (pool.isFull()) {
return c.json({ error: 'Service busy, please try again later' }, 503);
}
// Process CSV...
});
InternalRelease a worker back to the pool. For ReusableWorkerPool, this does nothing as workers are kept alive and reused.
The worker to release
Re-export the ReusableWorkerPool class with Web-specific createWorker.
This wrapper ensures the Web version of createWorker is used. All implementation details are in ReusableWorkerPool.shared.ts.