X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2FmultiFunctionExample.js;h=27a503256b776d163b29ad7a64a0a8d425ebf6c1;hb=670ede1cd02d1934860757fc7ea28ed0e963f6cc;hp=213736ea037899024da9e9aab20213ebf518de40;hpb=227be16668f5a3adf78a255c20e956d6f5b3f567;p=poolifier.git diff --git a/examples/multiFunctionExample.js b/examples/multiFunctionExample.js index 213736ea..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({ text: 'hello' }, 'fn0') - .then(res => console.log(res)) + .then(res => console.info(res)) .catch(err => console.error(err)) pool .execute({ text: 'multiple functions' }, 'fn1') - .then(res => console.log(res)) + .then(res => console.info(res)) .catch(err => console.error(err)) setTimeout(pool.destroy(), 3000)