refactor: refine benchmark namespace
[poolifier.git] / src / worker / cluster-worker.ts
index c820641ddbb10319b454bf5b25154312703cc446..4c1e118789d53f7228e51a5b974b80575985705f 100644 (file)
@@ -41,15 +41,13 @@ export class ClusterWorker<
       taskFunctions,
       opts
     )
-    if (!this.isMain) {
-      this.getMainWorker()?.on('message', this.messageListener.bind(this))
-    }
   }
 
   /** @inheritDoc */
   protected handleReadyMessage (message: MessageValue<Data>): void {
-    if (message.workerId === this.id && message.ready != null) {
-      !this.isMain && this.sendToMainWorker({ ready: true, workerId: this.id })
+    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 })
     }
   }