X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fthread%2Ffixed.ts;h=c9145f571186a9d5783531236414aff7eadd463e;hb=2826fc7a3ba7197b08fe5c352d8965b234f3abc5;hp=881e37f636eb3a5ba4770c0c7b90cbb994ab029e;hpb=e102732c0e3966b81834b2c0bdd087eb051162ad;p=poolifier.git diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 881e37f6..c9145f57 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -6,13 +6,8 @@ import { } from 'node:worker_threads' import type { MessageValue } from '../../utility-types' import { AbstractPool } from '../abstract-pool' -import { - type PoolOptions, - type PoolType, - PoolTypes, - type WorkerType, - WorkerTypes -} from '../pool' +import { type PoolOptions, type PoolType, PoolTypes } from '../pool' +import { type WorkerType, WorkerTypes } from '../worker' /** * Options for a poolifier thread pool. @@ -29,8 +24,6 @@ export interface ThreadPoolOptions extends PoolOptions { /** * A thread pool with a fixed number of threads. * - * It is possible to perform tasks in sync or asynchronous mode as you prefer. - * * @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data. * @typeParam Response - Type of execution response. This can only be structured-cloneable data. * @author [Alessandro Pio Ardizio](https://github.com/pioardi) @@ -62,7 +55,7 @@ export class FixedThreadPool< /** @inheritDoc */ protected async destroyWorker (worker: Worker): Promise { - this.sendToWorker(worker, { kill: 1 }) + this.sendToWorker(worker, { kill: true, workerId: worker.threadId }) await worker.terminate() }