X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2FmultiFunctionExample.js;h=055f143fdafae8ee1eb82e65f161d0f69f6b2e4e;hb=ae46e139246f3d30c073d78a06e817ca8bd02b36;hp=76b6bbfbff95a347c677e81c6587d5df8c1e2da6;hpb=87a12b1289a70e4b26f2ea40ba3cbfc2ad4d97ea;p=poolifier.git diff --git a/examples/multiFunctionExample.js b/examples/multiFunctionExample.js index 76b6bbfb..055f143f 100644 --- a/examples/multiFunctionExample.js +++ b/examples/multiFunctionExample.js @@ -1,12 +1,16 @@ -const FixedThreadPool = require('../lib/fixed') -const pool = new FixedThreadPool(15, './multifunctionWorker.js', { +const { FixedThreadPool } = require('poolifier') +const pool = new FixedThreadPool(15, './multiFunctionWorker.js', { errorHandler: e => console.error(e), - onlineHandler: () => console.log('worker is online') + onlineHandler: () => console.info('worker is online') }) -pool.execute({ fname: 'fn0', input: 'hello' }).then(res => console.log(res)) pool - .execute({ fname: 'fn1', input: 'multifunction' }) - .then(res => console.log(res)) + .execute({ text: 'hello' }, 'fn0') + .then(res => console.info(res)) + .catch(err => console.error(err)) +pool + .execute({ text: 'multiple functions' }, 'fn1') + .then(res => console.info(res)) + .catch(err => console.error(err)) -setTimeout(pool.destroy.bind(pool), 3000) +setTimeout(pool.destroy(), 3000)