| 1 | import { join } from 'path' |
| 2 | import { DynamicThreadPool, FixedThreadPool } from 'poolifier' |
| 3 | import type { MyData, MyResponse } from './worker' |
| 4 | |
| 5 | export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>( |
| 6 | 8, |
| 7 | join(__dirname, 'worker.js'), |
| 8 | { |
| 9 | errorHandler: e => console.error(e), |
| 10 | onlineHandler: () => console.log('Worker is online') |
| 11 | } |
| 12 | ) |
| 13 | |
| 14 | export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>( |
| 15 | 2, |
| 16 | 8, |
| 17 | join(__dirname, 'worker.js'), |
| 18 | { |
| 19 | errorHandler: e => console.error(e), |
| 20 | onlineHandler: () => console.log('Worker is online') |
| 21 | } |
| 22 | ) |