1 import type { IPool
} from
'./pool'
2 import type { IWorker
, WorkerNode
} from
'./worker'
21 * Internal contract definition for a poolifier pool.
23 * @typeParam Worker - Type of worker which manages this pool.
24 * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
25 * @typeParam Response - Type of response of execution. This can only be serializable data.
27 export interface IPoolInternal
<
28 Worker
extends IWorker
,
31 > extends IPool
<Data
, Response
> {
35 readonly workerNodes
: Array<WorkerNode
<Worker
, Data
>>
40 * If it is `'dynamic'`, it provides the `max` property.
42 readonly type: PoolType
45 * Whether the pool is full or not.
47 * The pool filling boolean status.
49 readonly full
: boolean
52 * Whether the pool is busy or not.
54 * The pool busyness boolean status.
56 readonly busy
: boolean
59 * Finds a free worker node key based on the number of tasks the worker has applied.
61 * If a worker is found with `0` running tasks, it is detected as free and its worker node key is returned.
63 * If no free worker is found, `-1` is returned.
65 * @returns A worker node key if there is one, `-1` otherwise.
67 findFreeWorkerNodeKey
: () => number