X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fpool.ts;h=c55c4e96557dc8fcb400847745b0ac2c5ee014c7;hb=96e265eb19e581dd0a73a788a9d641c9f13ce0cd;hp=de49c93ad6f8c73bc3cfaa680a78134cdd8daa56;hpb=31e4bacafa8f46d5ee2e015200f5f7037d3e731e;p=poolifier.git diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index de49c93a..c55c4e96 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,18 +1,20 @@ import { dirname, extname, join } from 'node:path' import { fileURLToPath } from 'node:url' -import type { MyData, MyResponse } from './worker' + import { + availableParallelism, DynamicThreadPool, - FixedThreadPool, - availableParallelism + FixedThreadPool } from 'poolifier' +import type { MyData, MyResponse } from './worker.js' + const workerFile = join( dirname(fileURLToPath(import.meta.url)), `worker${extname(fileURLToPath(import.meta.url))}` ) -export const fixedPool = new FixedThreadPool>( +export const fixedPool = new FixedThreadPool( availableParallelism(), workerFile, { @@ -25,7 +27,7 @@ export const fixedPool = new FixedThreadPool>( } ) -export const dynamicPool = new DynamicThreadPool>( +export const dynamicPool = new DynamicThreadPool( Math.floor(availableParallelism() / 2), availableParallelism(), workerFile,