X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultiFunctionExample.js;h=27a503256b776d163b29ad7a64a0a8d425ebf6c1;hb=23a6c28d3cc6edb778653a4d9d9a4d36f9a961c3;hp=6edc2bb7aaaa80b2d7ade610a09860785919d62d;hpb=1086026a2542abdcd0c5569d9afbfb8c2e628276;p=poolifier.git diff --git a/examples/multiFunctionExample.js b/examples/multiFunctionExample.js index 6edc2bb7..27a50325 100644 --- a/examples/multiFunctionExample.js +++ b/examples/multiFunctionExample.js @@ -1,16 +1,22 @@ -const { FixedThreadPool } = require('poolifier') -const pool = new FixedThreadPool(15, './multiFunctionWorker.js', { - errorHandler: e => console.error(e), - onlineHandler: () => console.log('worker is online') -}) +'use strict' +const { FixedThreadPool, availableParallelism } = require('poolifier') + +const pool = new FixedThreadPool( + availableParallelism(), + './multiFunctionWorker.js', + { + errorHandler: e => console.error(e), + onlineHandler: () => console.info('worker is online') + } +) pool - .execute({ functionName: 'fn0', input: 'hello' }) - .then(res => console.log(res)) + .execute({ text: 'hello' }, 'fn0') + .then(res => console.info(res)) .catch(err => console.error(err)) pool - .execute({ functionName: 'fn1', input: 'multiple functions' }) - .then(res => console.log(res)) + .execute({ text: 'multiple functions' }, 'fn1') + .then(res => console.info(res)) .catch(err => console.error(err)) -setTimeout(pool.destroy(pool), 3000) +setTimeout(pool.destroy(), 3000)