Bump json5 from 1.0.1 to 1.0.2 (#675)
[poolifier.git] / examples / typescript / pool.ts
... / ...
CommitLineData
1import { join } from 'path'
2import { DynamicThreadPool, FixedThreadPool } from 'poolifier'
3import type { MyData, MyResponse } from './worker'
4
5export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>(
6 8,
7 join(__dirname, 'worker.js'),
8 {
9 errorHandler: (e: Error) => console.error(e),
10 onlineHandler: () => console.log('Worker is online')
11 }
12)
13
14export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>(
15 2,
16 8,
17 join(__dirname, 'worker.js'),
18 {
19 errorHandler: (e: Error) => console.error(e),
20 onlineHandler: () => console.log('Worker is online')
21 }
22)