From: Jérôme Benoit Date: Wed, 19 Jul 2023 22:21:32 +0000 (+0200) Subject: refactor: cleanup worker id handling code X-Git-Tag: v2.6.19~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a038b5175071af7c51dae9e25c7423c7572f3949;p=poolifier.git refactor: cleanup worker id handling code Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index d7e3cc4b..dbf1d470 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -77,7 +77,7 @@ export class FixedClusterPool< protected sendStartupMessageToWorker (worker: Worker): void { this.sendToWorker(worker, { ready: false, - workerId: this.getWorkerInfoByWorker(worker).id as number + workerId: worker.id }) } diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index 52868fd7..e3a94b32 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -79,7 +79,7 @@ export class FixedThreadPool< worker.postMessage( { ready: false, - workerId: this.getWorkerInfoByWorker(worker).id as number, + workerId: worker.threadId, port: port2 }, [port2] diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 36b7d03e..67b4b5ff 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -284,6 +284,13 @@ export abstract class AbstractWorker< } } + /** + * Handles the ready message sent by the main worker. + * + * @param message - The ready message. + */ + protected abstract handleReadyMessage (message: MessageValue): void + /** * Worker message listener. * @@ -310,13 +317,6 @@ export abstract class AbstractWorker< } } - /** - * Handles the ready message sent by the main worker. - * - * @param message - The ready message. - */ - protected abstract handleReadyMessage (message: MessageValue): void - /** * Starts the worker check active interval. */