Commit | Line | Data |
---|---|---|
60fbd6d6 | 1 | const { FixedThreadPool } = require('poolifier') |
5c5a1fb7 | 2 | const pool = new FixedThreadPool(15, './multiFunctionWorker.js', { |
cf9aa6c3 | 3 | errorHandler: e => console.error(e), |
4 | onlineHandler: () => console.log('worker is online') | |
5 | }) | |
106744f7 | 6 | |
583a27ce | 7 | pool |
5c5a1fb7 | 8 | .execute({ functionName: 'fn0', input: 'hello' }) |
583a27ce JB |
9 | .then(res => console.log(res)) |
10 | .catch(err => console.error(err)) | |
cf9aa6c3 | 11 | pool |
5c5a1fb7 | 12 | .execute({ functionName: 'fn1', input: 'multiple functions' }) |
cf9aa6c3 | 13 | .then(res => console.log(res)) |
583a27ce | 14 | .catch(err => console.error(err)) |
106744f7 | 15 | |
16 | setTimeout(pool.destroy.bind(pool), 3000) |