Enhance default value for worker options handling
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Mar 2022 13:20:11 +0000 (14:20 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 4 Mar 2022 13:20:11 +0000 (14:20 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/worker/WorkerDynamicPool.ts
src/worker/WorkerSet.ts
src/worker/WorkerStaticPool.ts

index e68df35a812939fd086db3c720e922d0d221ad2a..a263335c1bd59682220be9ebcfdc281c0e067d6d 100644 (file)
@@ -16,7 +16,7 @@ export default class WorkerDynamicPool extends WorkerAbstract<WorkerData> {
    */
   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<WorkerData>(this.workerOptions.poolMinSize, this.workerOptions.poolMaxSize, this.workerScript, this.workerOptions.poolOptions);
   }
 
index 83e60df06f623e6ceaa0fb0ca1dedaa2c05b1a4d..81a6b05fdc3f1898c73cb99b18ed4a7f1bbf85a3 100644 (file)
@@ -19,8 +19,8 @@ export default class WorkerSet extends WorkerAbstract<WorkerData> {
    */
   constructor(workerScript: string, workerOptions?: WorkerOptions) {
     super(workerScript, workerOptions);
-    this.messageHandler = workerOptions?.messageHandler ?? (() => { /* This is intentional */ });
     this.workerSet = new Set<WorkerSetElement>();
+    this.messageHandler = workerOptions?.messageHandler ?? (() => { /* This is intentional */ });
   }
 
   get size(): number {
index 4e1e807c0953a171d8ecfc12fe3019a4cd919d73..818fd21af48f1c466b9e8dc8920ed94bb73a915a 100644 (file)
@@ -16,7 +16,7 @@ export default class WorkerStaticPool extends WorkerAbstract<WorkerData> {
    */
   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);
   }