X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=aa370fe433e74065e4155d8612499abef5ec59fb;hb=9cd39dd47830f0923cd3ebf53b709bf7fb07e788;hp=314c13c0cd02063a569a8ee5997a1d748b13cdbd;hpb=38e795c12f0e9daeff7b025147f36f85f486366e;p=poolifier.git diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index 314c13c0..aa370fe4 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -7,7 +7,7 @@ import type { } from './selection-strategies-types' /** - * Abstract worker choice strategy class. + * Worker choice strategy abstract base class. * * @typeParam Worker - Type of worker which manages the strategy. * @typeParam Data - Type of data sent to the worker. This can only be serializable data. @@ -17,12 +17,13 @@ export abstract class AbstractWorkerChoiceStrategy< Worker extends IPoolWorker, Data, Response -> implements IWorkerChoiceStrategy { +> implements IWorkerChoiceStrategy { /** {@inheritDoc} */ - public readonly isDynamicPool: boolean = this.pool.type === PoolType.DYNAMIC + public readonly isDynamicPool: boolean /** {@inheritDoc} */ public requiredStatistics: RequiredStatistics = { - runTime: false + runTime: false, + avgRunTime: false } /** @@ -32,11 +33,17 @@ export abstract class AbstractWorkerChoiceStrategy< */ public constructor ( protected readonly pool: IPoolInternal - ) {} + ) { + this.isDynamicPool = this.pool.type === PoolType.DYNAMIC + this.choose.bind(this) + } /** {@inheritDoc} */ public abstract reset (): boolean /** {@inheritDoc} */ - public abstract choose (): Worker + public abstract choose (): number + + /** {@inheritDoc} */ + public abstract remove (workerKey: number): boolean }