1 import type { WorkerChoiceStrategy
} from
'./selection-strategies'
4 * Contract definition for a poolifier pool.
6 * @template Data Type of data sent to the worker. This can only be serializable data.
7 * @template Response Type of response of execution. This can only be serializable data.
9 export interface IPool
<Data
= unknown
, Response
= unknown
> {
11 * Perform the task specified in the constructor with the data parameter.
13 * @param data The input for the specified task. This can only be serializable data.
14 * @returns Promise that will be resolved when the task is successfully completed.
16 execute(data
: Data
): Promise
<Response
>
18 * Shut down every current worker in this pool.
20 destroy(): Promise
<void>
22 * Set the worker choice strategy in this pool.
24 * @param workerChoiceStrategy The worker choice strategy.
26 setWorkerChoiceStrategy(workerChoiceStrategy
: WorkerChoiceStrategy
): void