261a9d7beeb862258ebabceef5b69a71df091180
1 import type { IPool
} from
'./pool'
2 import type { IPoolWorker
} from
'./pool-worker'
13 * Internal tasks usage statistics.
15 export interface TasksUsage
{
24 * Internal worker type.
26 * @typeParam Worker - Type of worker which manages this pool.
28 export interface WorkerType
<Worker
extends IPoolWorker
> {
30 tasksUsage
: TasksUsage
34 * Internal contract definition for a poolifier pool.
36 * @typeParam Worker - Type of worker which manages this pool.
37 * @typeParam Data - Type of data sent to the worker.
38 * @typeParam Response - Type of response of execution.
40 export interface IPoolInternal
<
41 Worker
extends IPoolWorker
,
44 > extends IPool
<Data
, Response
> {
46 * Pool workers item array.
48 readonly workers
: Array<WorkerType
<Worker
>>
53 * If it is `'dynamic'`, it provides the `max` property.
55 readonly type: PoolType
58 * Whether the pool is busy or not.
60 * The pool busyness boolean status.
62 readonly busy
: boolean
65 * Number of tasks currently concurrently running.
67 readonly numberOfRunningTasks
: number
70 * Finds a free worker key based on the number of tasks the worker has applied.
72 * If a worker is found with `0` running tasks, it is detected as free and its key is returned.
74 * If no free worker is found, `false` is returned.
76 * @returns A worker key if there is one, otherwise `false`.
78 findFreeWorkerKey
: () => number | false