X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fpool.ts;h=c55c4e96557dc8fcb400847745b0ac2c5ee014c7;hb=ea4b5fd037c5fe09eb6a2810332ad6bed1b5bc7f;hp=57898d98a9d53a8c89c3d774847e9cae694a53fe;hpb=d35e571704515a8b729d3455e4784054f07c368f;p=poolifier.git diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 57898d98..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.js' + 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,