X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2Fthread-worker.ts;h=75cd9da505b709a954f188ab209145221c90bc84;hb=493f77bdef6d66ad2fcb72b405c805274b24f3db;hp=03566a4c510265ddbd05f4ba24c1dbaef3c03195;hpb=48ef910747c7eafb18ebfff83d8eb24e5f5be26c;p=poolifier.git diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index 03566a4c..75cd9da5 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -1,6 +1,10 @@ import type { MessagePort } from 'node:worker_threads' import { isMainThread, parentPort } from 'node:worker_threads' -import type { MessageValue, WorkerFunction } from '../utility-types' +import type { + MessageValue, + TaskFunctions, + WorkerFunction +} from '../utility-types' import { AbstractWorker } from './abstract-worker' import type { WorkerOptions } from './worker-options' @@ -25,14 +29,22 @@ export class ThreadWorker< /** * Constructs a new poolifier thread worker. * - * @param fn - Function processed by the worker when the pool's `execution` function is invoked. + * @param taskFunctions - Task function(s) processed by the worker when the pool's `execution` function is invoked. * @param opts - Options for the worker. */ public constructor ( - fn: WorkerFunction, + taskFunctions: + | WorkerFunction + | TaskFunctions, opts: WorkerOptions = {} ) { - super('worker-thread-pool:poolifier', isMainThread, fn, parentPort, opts) + super( + 'worker-thread-pool:poolifier', + isMainThread, + taskFunctions, + parentPort, + opts + ) } /** @inheritDoc */