1 import type { IPool
} from
'./pool'
2 import type { IWorker
, WorkerNode
} from
'./worker'
15 * Internal contract definition for a poolifier pool.
17 * @typeParam Worker - Type of worker which manages this pool.
18 * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
19 * @typeParam Response - Type of response of execution. This can only be serializable data.
21 export interface IPoolInternal
<
22 Worker
extends IWorker
,
25 > extends IPool
<Data
, Response
> {
29 readonly workerNodes
: Array<WorkerNode
<Worker
, Data
>>
34 * If it is `'dynamic'`, it provides the `max` property.
36 readonly type: PoolType
39 * Whether the pool is full or not.
41 * The pool filling boolean status.
43 readonly full
: boolean
46 * Whether the pool is busy or not.
48 * The pool busyness boolean status.
50 readonly busy
: boolean
53 * Finds a free worker node key based on the number of tasks the worker has applied.
55 * If a worker is found with `0` running tasks, it is detected as free and its worker node key is returned.
57 * If no free worker is found, `-1` is returned.
59 * @returns A worker node key if there is one, `-1` otherwise.
61 findFreeWorkerNodeKey
: () => number