+ /** @inheritDoc */
+ protected handleReadyMessage (message: MessageValue<Data>): void {
+ if (
+ message.workerId === this.id &&
+ message.ready === false &&
+ message.port != null
+ ) {
+ try {
+ this.port = message.port
+ this.port.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 handleKillMessage (message: MessageValue<Data>): void {
+ super.handleKillMessage(message)
+ this.port?.unref()
+ this.port?.close()
+ }
+
+ /** @inheritDoc */
+ protected get id (): number {
+ return threadId
+ }
+