X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2FfixedExample.js;h=2346f7b4f0b68b207ced0df9ffd86f125e36a1e5;hb=f294681c4244effd6671e9d3534bf54bbf122d7a;hp=478c37eb056229360dbdbabcf61ab13e7f058e74;hpb=b99a3b7852074303d5e17781080235f30d68e6b6;p=poolifier.git diff --git a/examples/fixedExample.js b/examples/fixedExample.js index 478c37eb..2346f7b4 100644 --- a/examples/fixedExample.js +++ b/examples/fixedExample.js @@ -1,12 +1,17 @@ -const { FixedThreadPool, PoolEvents } = require('poolifier') -let resolved = 0 -let poolBusy = 0 -const pool = new FixedThreadPool(15, './yourWorker.js', { +const { + FixedThreadPool, + PoolEvents, + availableParallelism +} = require('poolifier') + +const pool = new FixedThreadPool(availableParallelism(), './yourWorker.js', { errorHandler: e => console.error(e), onlineHandler: () => console.info('worker is online') }) +let poolBusy = 0 pool.emitter.on(PoolEvents.busy, () => poolBusy++) +let resolved = 0 const start = performance.now() const iterations = 1000 for (let i = 1; i <= iterations; i++) {