6 } = require('poolifier')
8 const pool = new FixedThreadPool(availableParallelism(), './yourWorker.cjs', {
9 errorHandler: e => console.error(e),
10 onlineHandler: () => console.info('worker is online')
14 pool.emitter?.on(PoolEvents.ready, () => poolReady++)
15 pool.emitter?.on(PoolEvents.busy, () => poolBusy++)
18 const start = performance.now()
19 const iterations = 1000
20 for (let i = 1; i <= iterations; i++) {
25 if (resolved === iterations) {
27 `Time taken is ${(performance.now() - start).toFixed(2)}ms`
29 console.info(`The pool was ready for ${poolReady} times`)
30 console.info(`The pool was busy for ${poolBusy} times`)
35 .catch(err => console.error(err))