X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=examples%2Ftypescript%2Fpool.ts;h=54b437ab31b2f1d7785439c5ce9007167e554331;hb=a109e1c64ce3cff450fa79aebfa4de0ac3662be9;hp=869e62a8bf718020c155ae221b85921735a61d74;hpb=53795b86368cc6c3ec0648706fa385bdb6ca316d;p=poolifier.git diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 869e62a8..54b437ab 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,9 +1,13 @@ import { join } from 'path' import type { MyData, MyResponse } from './worker' -import { DynamicThreadPool, FixedThreadPool } from 'poolifier' +import { + DynamicThreadPool, + FixedThreadPool, + availableParallelism +} from 'poolifier' export const fixedPool = new FixedThreadPool>( - 8, + availableParallelism(), join(__dirname, 'worker.js'), { errorHandler: (e: Error) => { @@ -16,8 +20,8 @@ export const fixedPool = new FixedThreadPool>( ) export const dynamicPool = new DynamicThreadPool>( - 2, - 8, + Math.floor(availableParallelism() / 2), + availableParallelism(), join(__dirname, 'worker.js'), { errorHandler: (e: Error) => {