- super(
- 'worker-thread-pool:poolifier',
- isMainThread,
- taskFunctions,
- parentPort as MessagePort,
- opts
- )
- if (!this.isMain) {
- this.sendToMainWorker({ workerId: this.id, started: true })
+ super(isMainThread, parentPort as MessagePort, taskFunctions, opts)
+ }
+
+ /** @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,
+ taskFunctionNames: this.listTaskFunctionNames()
+ })
+ } catch {
+ this.sendToMainWorker({
+ ready: false,
+ taskFunctionNames: this.listTaskFunctionNames()
+ })
+ }