X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fpool.ts;h=144d55002bd048ea865365cb6696cdb887745230;hb=405b39c2835f645e2193dc30c3d190e3dcf3bc3e;hp=93774422b4500459715ec236c136c1601f13add4;hpb=9bc1ca7575fb508018f641dfee8c9939beda517a;p=poolifier.git diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 93774422..144d5500 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,6 +1,6 @@ -import { dirname, extname, join } from 'path' -import { fileURLToPath } from 'url' -import type { MyData, MyResponse } from './worker' +import { dirname, extname, join } from 'node:path' +import { fileURLToPath } from 'node:url' +import type { MyData, MyResponse } from './worker.js' import { DynamicThreadPool, FixedThreadPool, @@ -12,7 +12,7 @@ const workerFile = join( `worker${extname(fileURLToPath(import.meta.url))}` ) -export const fixedPool = new FixedThreadPool>( +export const fixedPool = new FixedThreadPool( availableParallelism(), workerFile, { @@ -25,7 +25,7 @@ export const fixedPool = new FixedThreadPool>( } ) -export const dynamicPool = new DynamicThreadPool>( +export const dynamicPool = new DynamicThreadPool( Math.floor(availableParallelism() / 2), availableParallelism(), workerFile, @@ -38,3 +38,9 @@ export const dynamicPool = new DynamicThreadPool>( } } ) + +// eslint-disable-next-line @typescript-eslint/no-misused-promises +setTimeout(async () => { + await fixedPool.destroy() + await dynamicPool.destroy() +}, 3000)