X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fthread-worker.ts;h=d5ce3a2f130da3efbe81f0aa0e3b3e7394033822;hb=d91689fda0fa7a85014ac25276cf2cf0a9d81ce2;hp=6f36664b8ae1a56cebb5058d7d4c56885b5ae88f;hpb=f05ed93ccebb3ea4212d015788bcd6ca9e0b38d2;p=poolifier.git diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index 6f36664b..d5ce3a2f 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -42,7 +42,7 @@ export class ThreadWorker< opts: WorkerOptions = {} ) { super( - 'worker-thread-pool:poolifier', + 'poolifier:thread-worker', isMainThread, parentPort as MessagePort, taskFunctions, @@ -60,10 +60,15 @@ export class ThreadWorker< try { this.port = message.port this.port.on('message', this.messageListener.bind(this)) - this.sendTaskFunctionsListToMainWorker() - this.sendToMainWorker({ ready: true, workerId: this.id }) + this.sendToMainWorker({ + ready: true, + taskFunctionNames: this.listTaskFunctionNames() + }) } catch { - this.sendToMainWorker({ ready: false, workerId: this.id }) + this.sendToMainWorker({ + ready: false, + taskFunctionNames: this.listTaskFunctionNames() + }) } } } @@ -82,11 +87,14 @@ export class ThreadWorker< /** @inheritDoc */ protected sendToMainWorker (message: MessageValue): void { - this.port.postMessage(message) + this.port.postMessage({ ...message, workerId: this.id }) } - /** @inheritDoc */ - protected handleError (e: Error | string): string { - return e as string + /** + * @inheritDoc + * @override + */ + protected handleError (error: Error | string): string { + return error as string } }