/**
* Message port used to communicate with the main worker.
*/
- private port!: MessagePort
+ private port?: MessagePort
/**
* Constructs a new poolifier thread worker.
*
taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
opts: WorkerOptions = {}
) {
- super(isMainThread, parentPort as MessagePort, taskFunctions)
+ super(isMainThread, parentPort as MessagePort, taskFunctions, opts)
}
/** @inheritDoc */
}
/** @inheritDoc */
- protected sendToMainWorker (message: MessageValue<Response>): void {
- this.port.postMessage({ ...message, workerId: this.id })
+ protected readonly sendToMainWorker = (
+ message: MessageValue<Response>
+ ): void => {
+ this.port?.postMessage({ ...message, workerId: this.id })
}
/**