- public constructor (fn: (data: Data) => Response, opts: WorkerOptions = {}) {
- super('worker-thread-pool:pioardi', isMainThread, fn, parentPort, opts)
+ public constructor (
+ taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>,
+ opts: WorkerOptions = {}
+ ) {
+ super(isMainThread, parentPort, 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,
+ taskFunctionsProperties: this.listTaskFunctionsProperties(),
+ })
+ } catch {
+ this.sendToMainWorker({
+ ready: false,
+ taskFunctionsProperties: this.listTaskFunctionsProperties(),
+ })
+ }
+ }