911e761df157a07f54ac1300328c82548cc6d9d6
1 import EventEmitter from
'events'
2 import type { IWorker
} from
'./abstract-pool'
3 import type { IPool
} from
'./pool'
6 * Internal poolifier pool emitter.
8 export class PoolEmitter
extends EventEmitter
{}
11 * Internal contract definition for a poolifier pool.
13 * @template Worker Type of worker which manages this pool.
14 * @template Data Type of data sent to the worker.
15 * @template Response Type of response of execution.
17 export interface IPoolInternal
<
18 Worker
extends IWorker
,
21 > extends IPool
<Data
, Response
> {
23 * List of currently available workers.
25 readonly workers
: Worker
[]
30 * - `key`: The `Worker`
31 * - `value`: Number of tasks currently in progress on the worker.
33 readonly tasks
: Map
<Worker
, number>
36 * Emitter on which events can be listened to.
38 * Events that can currently be listened to:
42 readonly emitter
: PoolEmitter
45 * Whether the pool is dynamic or not.
47 * If it is dynamic, it provides the `max` property.
49 readonly dynamic
: boolean
52 * Maximum number of workers that can be created by this pool.