1 const { FixedThreadPool
, PoolEvents
} = require('poolifier')
4 const pool
= new FixedThreadPool(15, './yourWorker.js', {
5 errorHandler
: e
=> console
.error(e
),
6 onlineHandler
: () => console
.log('worker is online')
8 pool
.emitter
.on(PoolEvents
.busy
, () => poolBusy
++)
10 const start
= performance
.now()
11 const iterations
= 1000
12 for (let i
= 1; i
<= iterations
; i
++) {
17 if (resolved
=== iterations
) {
18 console
.log('Time taken is ' + (performance
.now() - start
))
19 return console
.log('The pool was busy for ' + poolBusy
+ ' times')
23 .catch(err
=> console
.error(err
))