X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FstaticExample.js;h=d81e3484e89946374cc3056208e4d888a0162722;hb=ca027971126dd25bbc9dca1ef37844c01196a06c;hp=b9f7503fc8a4d656aa069f181c6ebdd679855d89;hpb=cf9aa6c3340ad00792aa3c5e1a9d047cd0140fc2;p=poolifier.git diff --git a/examples/staticExample.js b/examples/staticExample.js index b9f7503f..d81e3484 100644 --- a/examples/staticExample.js +++ b/examples/staticExample.js @@ -1,4 +1,4 @@ -const FixedThreadPool = require('../lib/fixed') +const { FixedThreadPool } = require('poolifier') let resolved = 0 const pool = new FixedThreadPool(15, './yourWorker.js', { errorHandler: e => console.error(e), @@ -8,10 +8,14 @@ const pool = new FixedThreadPool(15, './yourWorker.js', { 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)) }