From: Jérôme Benoit Date: Fri, 4 Mar 2022 13:20:11 +0000 (+0100) Subject: Enhance default value for worker options handling X-Git-Tag: v1.1.50~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5767874516784070db4445321b5212ad7e5a84b4;p=e-mobility-charging-stations-simulator.git Enhance default value for worker options handling Signed-off-by: Jérôme Benoit --- diff --git a/src/worker/WorkerDynamicPool.ts b/src/worker/WorkerDynamicPool.ts index e68df35a..a263335c 100644 --- a/src/worker/WorkerDynamicPool.ts +++ b/src/worker/WorkerDynamicPool.ts @@ -16,7 +16,7 @@ export default class WorkerDynamicPool extends WorkerAbstract { */ constructor(workerScript: string, workerOptions?: WorkerOptions) { super(workerScript, workerOptions); - this.workerOptions.poolOptions.exitHandler = workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler; + this.workerOptions.poolOptions.exitHandler = this.workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler; this.pool = new DynamicThreadPool(this.workerOptions.poolMinSize, this.workerOptions.poolMaxSize, this.workerScript, this.workerOptions.poolOptions); } diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index 83e60df0..81a6b05f 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -19,8 +19,8 @@ export default class WorkerSet extends WorkerAbstract { */ constructor(workerScript: string, workerOptions?: WorkerOptions) { super(workerScript, workerOptions); - this.messageHandler = workerOptions?.messageHandler ?? (() => { /* This is intentional */ }); this.workerSet = new Set(); + this.messageHandler = workerOptions?.messageHandler ?? (() => { /* This is intentional */ }); } get size(): number { diff --git a/src/worker/WorkerStaticPool.ts b/src/worker/WorkerStaticPool.ts index 4e1e807c..818fd21a 100644 --- a/src/worker/WorkerStaticPool.ts +++ b/src/worker/WorkerStaticPool.ts @@ -16,7 +16,7 @@ export default class WorkerStaticPool extends WorkerAbstract { */ constructor(workerScript: string, workerOptions?: WorkerOptions) { super(workerScript, workerOptions); - this.workerOptions.poolOptions.exitHandler = workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler; + this.workerOptions.poolOptions.exitHandler = this.workerOptions?.poolOptions?.exitHandler ?? WorkerUtils.defaultExitHandler; this.pool = new FixedThreadPool(this.workerOptions.poolMaxSize, this.workerScript, this.workerOptions.poolOptions); }