X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=2ee3a0ccb968100e23a5deecfe2eb4e049171875;hb=80b875e3940ad36bd494fdadea97a070c46251be;hp=b299bc0172e839fdc57e165bd8e1391200a17885;hpb=e0ae6100cd739a48d38b4794c1e55437ac3b59eb;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index b299bc01..2ee3a0cc 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -6,14 +6,15 @@ import { median } from '../utils' import { KillBehaviors, isKillBehavior } from '../worker/worker-options' +import { CircularArray } from '../circular-array' import { - PoolEvents, type IPool, + PoolEmitter, + PoolEvents, type PoolOptions, - type TasksQueueOptions, - PoolType + PoolType, + type TasksQueueOptions } from './pool' -import { PoolEmitter } from './pool' import type { IWorker, Task, TasksUsage, WorkerNode } from './worker' import { WorkerChoiceStrategies, @@ -21,7 +22,6 @@ import { type WorkerChoiceStrategyOptions } from './selection-strategies/selection-strategies-types' import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context' -import { CircularArray } from '../circular-array' /** * Base class that implements some shared logic for all poolifier pools. @@ -387,7 +387,7 @@ export abstract class AbstractPool< worker: Worker, message: MessageValue ): void { - const workerTasksUsage = this.getWorkerTasksUsage(worker) as TasksUsage + const workerTasksUsage = this.getWorkerTasksUsage(worker) --workerTasksUsage.running ++workerTasksUsage.run if (message.error != null) { @@ -428,7 +428,7 @@ export abstract class AbstractPool< ) { // Kill message received from the worker: no new tasks are submitted to that worker for a while ( > maxInactiveTime) this.flushTasksQueueByWorker(workerCreated) - void this.destroyWorker(workerCreated) + void (this.destroyWorker(workerCreated) as Promise) } }) workerNodeKey = this.getWorkerNodeKey(workerCreated) @@ -560,7 +560,7 @@ export abstract class AbstractPool< * @throws Error if the worker is not found in the pool worker nodes. * @returns The worker tasks usage. */ - private getWorkerTasksUsage (worker: Worker): TasksUsage | undefined { + private getWorkerTasksUsage (worker: Worker): TasksUsage { const workerNodeKey = this.getWorkerNodeKey(worker) if (workerNodeKey !== -1) { return this.workerNodes[workerNodeKey].tasksUsage