1 import type { IPool
} from
'./pool'
2 import type { IPoolWorker
} from
'./pool-worker'
15 * Internal tasks usage statistics.
17 export interface TasksUsage
{
26 * Internal worker type.
28 * @typeParam Worker - Type of worker type items which manages this pool.
30 export interface WorkerType
<Worker
extends IPoolWorker
> {
32 tasksUsage
: TasksUsage
36 * Internal contract definition for a poolifier pool.
38 * @typeParam Worker - Type of worker which manages this pool.
39 * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
40 * @typeParam Response - Type of response of execution. This can only be serializable data.
42 export interface IPoolInternal
<
43 Worker
extends IPoolWorker
,
46 > extends IPool
<Data
, Response
> {
48 * Pool worker type items array.
50 readonly workers
: Array<WorkerType
<Worker
>>
55 * If it is `'dynamic'`, it provides the `max` property.
57 readonly type: PoolType
60 * Whether the pool is full or not.
62 * The pool filling boolean status.
64 readonly full
: boolean
67 * Whether the pool is busy or not.
69 * The pool busyness boolean status.
71 readonly busy
: boolean
74 * Finds a free worker key based on the number of tasks the worker has applied.
76 * If a worker is found with `0` running tasks, it is detected as free and its key is returned.
78 * If no free worker is found, `-1` is returned.
80 * @returns A worker key if there is one, `-1` otherwise.
82 findFreeWorkerKey
: () => number