fix: fix dynamic pool busy semantic
[poolifier.git] / src / pools / cluster / dynamic.ts
index 8b8c5185772dbea59bc0d22b2e1cb90b9383d507..c4fc788cd8dcdd0528bca2234caead2d9fc70ccd 100644 (file)
@@ -27,7 +27,7 @@ export class DynamicClusterPool<
    */
   public constructor (
     min: number,
-    protected readonly max: number,
+    private readonly max: number,
     filePath: string,
     opts: ClusterPoolOptions = {}
   ) {
@@ -40,7 +40,12 @@ export class DynamicClusterPool<
   }
 
   /** {@inheritDoc} */
-  public get busy (): boolean {
+  public get full (): boolean {
     return this.workers.length === this.max
   }
+
+  /** {@inheritDoc} */
+  public get busy (): boolean {
+    return this.full && this.findFreeWorkerKey() === -1
+  }
 }