---
[poolifier.git] / examples / javascript / multiFunctionExample.cjs
... / ...
CommitLineData
1'use strict'
2const { FixedThreadPool, availableParallelism } = require('poolifier')
3
4const pool = new FixedThreadPool(
5 availableParallelism(),
6 './multiFunctionWorker.cjs',
7 {
8 onlineHandler: () => console.info('worker is online'),
9 errorHandler: e => console.error(e)
10 }
11)
12
13pool
14 .execute({ text: 'hello' }, 'fn0')
15 .then(res => console.info(res))
16 .catch(err => console.error(err))
17pool
18 .execute({ text: 'multiple functions' }, 'fn1')
19 .then(res => console.info(res))
20 .catch(err => console.error(err))
21
22setTimeout(async () => await pool.destroy(), 3000)