X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fthread%2Ffixed.ts;h=e3f9602cd93cdfc3a3e03b3ab7860fe25cdb5135;hb=9c8526b801b42a5b40bfa5cec6f6e2082ffc9da7;hp=abd1b6b8b081ac2740ac96ea6a1265a690ff407b;hpb=7c0ba92006a5c188738ffc5ff642c51f172df3d6;p=poolifier.git diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index abd1b6b8..e3f9602c 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -16,9 +16,8 @@ export type ThreadWorkerWithMessageChannel = Worker & Draft * * This pool selects the threads in a round robin fashion. * - * @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. - * + * @template DataType of data sent to the worker. This can only be serializable data. + * @template ResponseType of response of execution. This can only be serializable data. * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ @@ -31,7 +30,7 @@ export class FixedThreadPool< * * @param numberOfThreads Number of threads for this pool. * @param filePath Path to an implementation of a `ThreadWorker` file, which can be relative or absolute. - * @param opts Options for this fixed thread pool. Default: `{}` + * @param [opts={}] Options for this fixed thread pool. */ public constructor ( numberOfThreads: number, @@ -41,6 +40,7 @@ export class FixedThreadPool< super(numberOfThreads, filePath, opts) } + /** @inheritdoc */ protected isMain (): boolean { return isMainThread } @@ -53,6 +53,7 @@ export class FixedThreadPool< await worker.terminate() } + /** @inheritdoc */ protected sendToWorker ( worker: ThreadWorkerWithMessageChannel, message: MessageValue @@ -68,12 +69,14 @@ export class FixedThreadPool< messageChannel.port2?.on('message', listener) } + /** @inheritdoc */ protected createWorker (): ThreadWorkerWithMessageChannel { return new Worker(this.filePath, { env: SHARE_ENV }) } + /** @inheritdoc */ protected afterWorkerSetup (worker: ThreadWorkerWithMessageChannel): void { const { port1, port2 } = new MessageChannel() worker.postMessage({ parent: port1 }, [port1])