- /** {@inheritDoc} */
- protected sendToMainWorker (message: MessageValue<Response>): void {
- this.getMainWorker().send(message)
+ /** @inheritDoc */
+ protected handleReadyMessage (message: MessageValue<Data>): void {
+ if (message.workerId === this.id && message.ready === false) {
+ try {
+ this.getMainWorker().on('message', this.messageListener.bind(this))
+ this.sendToMainWorker({
+ ready: true,
+ taskFunctions: this.listTaskFunctions(),
+ workerId: this.id
+ })
+ } catch {
+ this.sendToMainWorker({
+ ready: false,
+ taskFunctions: this.listTaskFunctions(),
+ workerId: this.id
+ })
+ }
+ }
+ }
+
+ /** @inheritDoc */
+ protected get id (): number {
+ return this.getMainWorker().id