X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fpool-internal.ts;h=3f35ec13e25b79e67c3cb2c9084843adcbf63f99;hb=2f8c5b5c1182f698efe07d327359bef934af3a29;hp=f5f1d1908a14d60f2e26f9d6baa75c627468e96b;hpb=bf9549aef8a23a3931e19040dadb7f1e8e6422b5;p=poolifier.git diff --git a/src/pools/pool-internal.ts b/src/pools/pool-internal.ts index f5f1d190..3f35ec13 100644 --- a/src/pools/pool-internal.ts +++ b/src/pools/pool-internal.ts @@ -1,6 +1,6 @@ import EventEmitter from 'events' -import type { AbstractPoolWorker } from './abstract-pool-worker' import type { IPool } from './pool' +import type { IPoolWorker } from './pool-worker' /** * Pool types. @@ -33,7 +33,7 @@ export class PoolEmitter extends EventEmitter {} * @template Response Type of response of execution. */ export interface IPoolInternal< - Worker extends AbstractPoolWorker, + Worker extends IPoolWorker, Data = unknown, Response = unknown > extends IPool { @@ -42,6 +42,14 @@ export interface IPoolInternal< */ readonly workers: Worker[] + /** + * The workers tasks usage map. + * + * `key`: The `Worker` + * `value`: Worker tasks usage statistics. + */ + readonly workersTasksUsage: Map + /** * Emitter on which events can be listened to. * @@ -76,7 +84,7 @@ export interface IPoolInternal< readonly numberOfRunningTasks: number /** - * Find a free worker based on the number of tasks the worker has applied. + * Finds a free worker based on the number of tasks the worker has applied. * * If a worker is found with `0` running tasks, it is detected as free and returned. * @@ -87,7 +95,7 @@ export interface IPoolInternal< findFreeWorker(): Worker | false /** - * Get worker index. + * Gets worker index. * * @param worker The worker. * @returns The worker index. @@ -95,7 +103,7 @@ export interface IPoolInternal< getWorkerIndex(worker: Worker): number /** - * Get worker running tasks. + * Gets worker running tasks. * * @param worker The worker. * @returns The number of tasks currently running on the worker. @@ -103,10 +111,10 @@ export interface IPoolInternal< getWorkerRunningTasks(worker: Worker): number | undefined /** - * Get worker average tasks run time. + * Gets worker average tasks runtime. * * @param worker The worker. - * @returns The average tasks run time on the worker. + * @returns The average tasks runtime on the worker. */ getWorkerAverageTasksRunTime(worker: Worker): number | undefined }