X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=43abfda76c5ed9d07e3ae98fdecb6e40b5f9b025;hb=9b2bdf941262ef1dd0d113330463b304cc56a189;hp=55c380b80c5b92de72bb1c4c87e57f4614c56f37;hpb=184855e69fea29f1018024a34be10de2c8e3141a;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 55c380b8..43abfda7 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -78,9 +78,9 @@ export abstract class AbstractPool< * @param opts - Options for the pool. */ public constructor ( - public readonly numberOfWorkers: number, - public readonly filePath: string, - public readonly opts: PoolOptions + protected readonly numberOfWorkers: number, + protected readonly filePath: string, + protected readonly opts: PoolOptions ) { if (!this.isMain()) { throw new Error('Cannot start a pool from a worker!') @@ -211,9 +211,6 @@ export abstract class AbstractPool< } } - /** @inheritDoc */ - public abstract get type (): PoolType - /** @inheritDoc */ public get info (): PoolInfo { return { @@ -249,6 +246,13 @@ export abstract class AbstractPool< } } + /** + * Pool type. + * + * If it is `'dynamic'`, it provides the `max` property. + */ + protected abstract get type (): PoolType + /** * Gets the worker type. */ @@ -353,7 +357,9 @@ export abstract class AbstractPool< * * The pool filling boolean status. */ - protected abstract get full (): boolean + protected get full (): boolean { + return this.workerNodes.length >= this.maxSize + } /** * Whether the pool is busy or not. @@ -410,6 +416,7 @@ export abstract class AbstractPool< await Promise.all( this.workerNodes.map(async (workerNode, workerNodeKey) => { this.flushTasksQueue(workerNodeKey) + // FIXME: wait for tasks to be finished await this.destroyWorker(workerNode.worker) }) ) @@ -535,6 +542,7 @@ export abstract class AbstractPool< ) { // Kill message received from the worker: no new tasks are submitted to that worker for a while ( > maxInactiveTime) this.flushTasksQueue(currentWorkerNodeKey) + // FIXME: wait for tasks to be finished void (this.destroyWorker(workerCreated) as Promise) } })