X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FstaticExample.js;h=d81e3484e89946374cc3056208e4d888a0162722;hb=deb85c12b77faf6974551cefcd9676e62a392086;hp=49dc02a54533254efb32466e944228375fccc653;hpb=c68d4281d92ef0da01fc89fb00a93d3a17ba392e;p=poolifier.git diff --git a/examples/staticExample.js b/examples/staticExample.js index 49dc02a5..d81e3484 100644 --- a/examples/staticExample.js +++ b/examples/staticExample.js @@ -1,16 +1,21 @@ -const FixedThreadPool = require('../lib/fixed') +const { FixedThreadPool } = require('poolifier') let resolved = 0 -const pool = new FixedThreadPool(15, - './yourWorker.js', - { errorHandler: (e) => console.error(e), onlineHandler: () => console.log('worker is online') }) +const pool = new FixedThreadPool(15, './yourWorker.js', { + errorHandler: e => console.error(e), + onlineHandler: () => console.log('worker is online') +}) const start = Date.now() const iterations = 1000 for (let i = 0; i <= iterations; i++) { - pool.execute({}).then(res => { - resolved++ - if (resolved === iterations) { - console.log('Time take is ' + (Date.now() - start)) - } - }) + pool + .execute({}) + .then(res => { + resolved++ + if (resolved === iterations) { + return console.log('Time take is ' + (Date.now() - start)) + } + return null + }) + .catch(err => console.error(err)) }