X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fthread%2Ffixed.ts;h=a61c10b2346c8a44c4094605dfe6aa25787b8f09;hb=deb85c12b77faf6974551cefcd9676e62a392086;hp=705f124aea4dda5f35234dea3f8d2f1b59e827a6;hpb=4f7fa42a78e36031814421ba6310586da9dd46d2;p=poolifier.git diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 705f124a..a61c10b2 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -1,5 +1,5 @@ import { isMainThread, MessageChannel, SHARE_ENV, Worker } from 'worker_threads' -import type { Draft, JSONValue, MessageValue } from '../../utility-types' +import type { Draft, MessageValue } from '../../utility-types' import type { PoolOptions } from '../abstract-pool' import { AbstractPool } from '../abstract-pool' @@ -15,15 +15,15 @@ export type ThreadWorkerWithMessageChannel = Worker & Draft * * This pool selects the threads in a round robin fashion. * - * @template Data Type of data sent to the worker. - * @template Response Type of response of execution. + * @template Data Type of data sent to the worker. This can only be serializable data. + * @template Response Type of response of execution. This can only be serializable data. * * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ export class FixedThreadPool< - Data extends JSONValue = JSONValue, - Response extends JSONValue = JSONValue + Data = unknown, + Response = unknown > extends AbstractPool { /** * Constructs a new poolifier fixed thread pool. @@ -47,6 +47,7 @@ export class FixedThreadPool< protected async destroyWorker ( worker: ThreadWorkerWithMessageChannel ): Promise { + this.sendToWorker(worker, { kill: 1 }) await worker.terminate() }