1 import { dirname
, join
} from
'path'
2 import { fileURLToPath
} from
'url'
3 import type { MyData
, MyResponse
} from
'./worker'
10 export const fixedPool
= new FixedThreadPool
<MyData
, Promise
<MyResponse
>>(
11 availableParallelism(),
12 join(dirname(fileURLToPath(import.meta
.url
)), 'worker.js'),
14 errorHandler
: (e
: Error) => {
17 onlineHandler
: () => {
18 console
.info('Worker is online')
23 export const dynamicPool
= new DynamicThreadPool
<MyData
, Promise
<MyResponse
>>(
24 Math.floor(availableParallelism() / 2),
25 availableParallelism(),
26 join(dirname(fileURLToPath(import.meta
.url
)), 'worker.js'),
28 errorHandler
: (e
: Error) => {
31 onlineHandler
: () => {
32 console
.info('Worker is online')