Data = unknown,
Response = unknown
> implements IPoolInternal<Worker, Data, Response> {
- /** @inheritdoc */
+ /** @inheritDoc */
public readonly workers: Worker[] = []
- /** @inheritdoc */
+ /** @inheritDoc */
public readonly tasks: Map<Worker, number> = new Map<Worker, number>()
- /** @inheritdoc */
+ /** @inheritDoc */
public readonly emitter?: PoolEmitter
- /** @inheritdoc */
+ /** @inheritDoc */
public readonly max?: number
/**
this.opts.enableEvents = opts.enableEvents ?? true
}
- /** @inheritdoc */
+ /** @inheritDoc */
public abstract get type (): PoolType
- /** @inheritdoc */
+ /** @inheritDoc */
public get numberOfRunningTasks (): number {
return this.promiseMap.size
}
- /** @inheritdoc */
+ /** @inheritDoc */
public getWorkerRunningTasks (worker: Worker): number | undefined {
return this.tasks.get(worker)
}
- /** @inheritdoc */
+ /** @inheritDoc */
public getWorkerIndex (worker: Worker): number {
return this.workers.indexOf(worker)
}
- /** @inheritdoc */
+ /** @inheritDoc */
public setWorkerChoiceStrategy (
workerChoiceStrategy: WorkerChoiceStrategy
): void {
)
}
- /** @inheritdoc */
+ /** @inheritDoc */
public abstract get busy (): boolean
protected internalGetBusyStatus (): boolean {
)
}
- /** @inheritdoc */
+ /** @inheritDoc */
public findFreeWorker (): Worker | false {
for (const worker of this.workers) {
if (this.getWorkerRunningTasks(worker) === 0) {
return false
}
- /** @inheritdoc */
+ /** @inheritDoc */
public execute (data: Data): Promise<Response> {
// Configure worker to handle message with the specified task
const worker = this.chooseWorker()
return res
}
- /** @inheritdoc */
+ /** @inheritDoc */
public async destroy (): Promise<void> {
await Promise.all(this.workers.map(worker => this.destroyWorker(worker)))
}