refactor: cleanup performance statistics code
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerFactory.ts
index a5b401a3698417887c77426f843d0cae48bd61f0..35fe82eb4c73a017d01316e265ddc7348fc72025 100644 (file)
@@ -1,6 +1,6 @@
-import { type Worker, isMainThread } from 'node:worker_threads';
+import { isMainThread } from 'node:worker_threads';
 
-import type { PoolOptions } from 'poolifier';
+import type { ThreadPoolOptions } from 'poolifier';
 
 import type { WorkerAbstract } from './WorkerAbstract';
 import { WorkerConstants } from './WorkerConstants';
@@ -22,15 +22,12 @@ export class WorkerFactory {
     if (!isMainThread) {
       throw new Error('Cannot get a worker implementation outside the main thread');
     }
-    workerOptions = workerOptions ?? (WorkerConstants.EMPTY_OBJECT as WorkerOptions);
+    workerOptions = workerOptions ?? ({} as WorkerOptions);
     workerOptions.workerStartDelay =
       workerOptions?.workerStartDelay ?? WorkerConstants.DEFAULT_WORKER_START_DELAY;
     workerOptions.elementStartDelay =
       workerOptions?.elementStartDelay ?? WorkerConstants.DEFAULT_ELEMENT_START_DELAY;
-    workerOptions.poolOptions =
-      workerOptions?.poolOptions ?? (WorkerConstants.EMPTY_OBJECT as PoolOptions<Worker>);
-    workerOptions?.messageHandler &&
-      (workerOptions.poolOptions.messageHandler = workerOptions.messageHandler);
+    workerOptions.poolOptions = workerOptions?.poolOptions ?? ({} as ThreadPoolOptions);
     let workerImplementation: WorkerAbstract<T> | null = null;
     switch (workerProcessType) {
       case WorkerProcessType.workerSet: