Merge branch 'master' into improve-ci
[poolifier.git] / examples / typescript / pool.ts
1 import { DynamicThreadPool, FixedThreadPool } from 'poolifier'
2 import { MyData, MyResponse } from './worker'
3
4 import { join } from 'path'
5
6 export const fixedPool = new FixedThreadPool<MyData, Promise<MyResponse>>(
7 8,
8 join(__dirname, 'worker.js'),
9 {
10 errorHandler: e => console.error(e),
11 onlineHandler: () => console.log('Worker is online')
12 }
13 )
14
15 export const dynamicPool = new DynamicThreadPool<MyData, Promise<MyResponse>>(
16 2,
17 8,
18 join(__dirname, 'worker.js'),
19 {
20 errorHandler: e => console.error(e),
21 onlineHandler: () => console.log('Worker is online')
22 }
23 )