Pool busy event emitting on all pool types (#241)
[poolifier.git] / examples / multiFunctionExample.js
... / ...
CommitLineData
1const { FixedThreadPool } = require('poolifier')
2const pool = new FixedThreadPool(15, './multiFunctionWorker.js', {
3 errorHandler: e => console.error(e),
4 onlineHandler: () => console.log('worker is online')
5})
6
7pool
8 .execute({ functionName: 'fn0', input: 'hello' })
9 .then(res => console.log(res))
10 .catch(err => console.error(err))
11pool
12 .execute({ functionName: 'fn1', input: 'multiple functions' })
13 .then(res => console.log(res))
14 .catch(err => console.error(err))
15
16setTimeout(pool.destroy.bind(pool), 3000)