// a fixed worker_threads pool
const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
})
pool.emitter?.on(PoolEvents.ready, () => console.info('Pool is ready'))
// or a dynamic worker_threads pool
const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), './yourWorker.js', {
- errorHandler: e => console.error(e),
- onlineHandler: () => console.info('worker is online')
+ onlineHandler: () => console.info('worker is online'),
+ errorHandler: e => console.error(e)
})
pool.emitter?.on(PoolEvents.full, () => console.info('Pool is full'))