refactor: refine benchmark namespace
[poolifier.git] / src / worker / cluster-worker.ts
index c43e7f75a7586d2b2a9fa6633eea7da6e44697bf..4c1e118789d53f7228e51a5b974b80575985705f 100644 (file)
@@ -37,12 +37,20 @@ export class ClusterWorker<
     super(
       'worker-cluster-pool:poolifier',
       cluster.isPrimary,
-      taskFunctions,
       cluster.worker as Worker,
+      taskFunctions,
       opts
     )
   }
 
+  /** @inheritDoc */
+  protected handleReadyMessage (message: MessageValue<Data>): void {
+    if (!this.isMain && message.workerId === this.id && message.ready != null) {
+      this.getMainWorker()?.on('message', this.messageListener.bind(this))
+      this.sendToMainWorker({ ready: true, workerId: this.id })
+    }
+  }
+
   /** @inheritDoc */
   protected get id (): number {
     return this.getMainWorker().id