return { ok: 1 }
}
-module.exports = new ThreadWorker(yourFunction, {
- maxInactiveTime: 60000
+export default new ThreadWorker(yourFunction, {
+ maxInactiveTime: 60000,
})
```
// a fixed worker_threads pool
const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', {
onlineHandler: () => console.info('worker is online'),
- errorHandler: e => console.error(e)
+ 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', {
onlineHandler: () => console.info('worker is online'),
- errorHandler: e => console.error(e)
+ errorHandler: e => console.error(e),
})
pool.emitter?.on(PoolEvents.full, () => console.info('Pool is full'))