X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=examples%2Ftypescript%2Fpool.ts;h=93774422b4500459715ec236c136c1601f13add4;hb=023bd558ccd496d78a0ecc281131a6548989865e;hp=54b437ab31b2f1d7785439c5ce9007167e554331;hpb=31a7d5bea6971eff8079efd2a164a66086f6d4b3;p=poolifier.git diff --git a/examples/typescript/pool.ts b/examples/typescript/pool.ts index 54b437ab..93774422 100644 --- a/examples/typescript/pool.ts +++ b/examples/typescript/pool.ts @@ -1,4 +1,5 @@ -import { join } from 'path' +import { dirname, extname, join } from 'path' +import { fileURLToPath } from 'url' import type { MyData, MyResponse } from './worker' import { DynamicThreadPool, @@ -6,9 +7,14 @@ import { availableParallelism } from 'poolifier' +const workerFile = join( + dirname(fileURLToPath(import.meta.url)), + `worker${extname(fileURLToPath(import.meta.url))}` +) + export const fixedPool = new FixedThreadPool>( availableParallelism(), - join(__dirname, 'worker.js'), + workerFile, { errorHandler: (e: Error) => { console.error(e) @@ -22,7 +28,7 @@ export const fixedPool = new FixedThreadPool>( export const dynamicPool = new DynamicThreadPool>( Math.floor(availableParallelism() / 2), availableParallelism(), - join(__dirname, 'worker.js'), + workerFile, { errorHandler: (e: Error) => { console.error(e)