X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fthread-worker.ts;h=09135afffc913dd7b983b7cbac9134bb5573b3b3;hb=fb1a03c56c9285f28d04940fad413cfa0132acf7;hp=b6573a974cc653656fb6a968b0437e57eeed7dd6;hpb=e102732c0e3966b81834b2c0bdd087eb051162ad;p=poolifier.git diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index b6573a97..09135aff 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -1,4 +1,9 @@ -import { type MessagePort, isMainThread, parentPort } from 'node:worker_threads' +import { + type MessagePort, + isMainThread, + parentPort, + threadId +} from 'node:worker_threads' import type { MessageValue } from '../utility-types' import { AbstractWorker } from './abstract-worker' import type { WorkerOptions } from './worker-options' @@ -43,8 +48,17 @@ export class ThreadWorker< ) } + protected get id (): number { + return threadId + } + /** @inheritDoc */ protected sendToMainWorker (message: MessageValue): void { this.getMainWorker().postMessage(message) } + + /** @inheritDoc */ + protected handleError (e: Error | string): string { + return e as string + } }