X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultiFunctionExample.js;h=31fd8809613f7e2b86783a53bb16e9972128743c;hb=15bb637a91abd156aae586ce14c663101a8c6697;hp=d1314aa94149fe7324fda3df0b91e240f9865532;hpb=60fbd6d6188b0902d157fd0cde04d6af3a391e32;p=poolifier.git diff --git a/examples/multiFunctionExample.js b/examples/multiFunctionExample.js index d1314aa9..31fd8809 100644 --- a/examples/multiFunctionExample.js +++ b/examples/multiFunctionExample.js @@ -1,12 +1,16 @@ const { FixedThreadPool } = require('poolifier') -const pool = new FixedThreadPool(15, './multifunctionWorker.js', { +const pool = new FixedThreadPool(15, './multiFunctionWorker.js', { errorHandler: e => console.error(e), onlineHandler: () => console.log('worker is online') }) -pool.execute({ fname: 'fn0', input: 'hello' }).then(res => console.log(res)) pool - .execute({ fname: 'fn1', input: 'multifunction' }) + .execute({ functionName: 'fn0', input: 'hello' }) .then(res => console.log(res)) + .catch(err => console.error(err)) +pool + .execute({ functionName: 'fn1', input: 'multiple functions' }) + .then(res => console.log(res)) + .catch(err => console.error(err)) -setTimeout(pool.destroy.bind(pool), 3000) +setTimeout(pool.destroy(), 3000)