fix: fix tasks usage initialization
[poolifier.git] / src / pools / thread / fixed.ts
index a95a86034fcf13abc471862bbe9d51d8aa4604d1..3dc10821e2cdb9198e3eea62e287a4fc4d8aa425 100644 (file)
@@ -7,7 +7,7 @@ import {
 import type { Draft, MessageValue } from '../../utility-types'
 import { AbstractPool } from '../abstract-pool'
 import type { PoolOptions } from '../pool'
-import { PoolType } from '../pool-internal'
+import { PoolType } from '../pool'
 
 /**
  * A thread worker with message channels for communication between main thread and thread worker.
@@ -22,7 +22,7 @@ export type ThreadWorkerWithMessageChannel = Worker & Draft<MessageChannel>
  * This pool selects the threads in a round robin fashion.
  *
  * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of response of execution. This can only be serializable data.
+ * @typeParam Response - Type of execution response. This can only be serializable data.
  * @author [Alessandro Pio Ardizio](https://github.com/pioardi)
  * @since 0.0.1
  */
@@ -51,7 +51,7 @@ export class FixedThreadPool<
   }
 
   /** @inheritDoc */
-  public async destroyWorker (
+  protected async destroyWorker (
     worker: ThreadWorkerWithMessageChannel
   ): Promise<void> {
     this.sendToWorker(worker, { kill: 1 })
@@ -67,7 +67,7 @@ export class FixedThreadPool<
   }
 
   /** @inheritDoc */
-  public registerWorkerMessageListener<Message extends Data | Response>(
+  protected registerWorkerMessageListener<Message extends Data | Response>(
     messageChannel: ThreadWorkerWithMessageChannel,
     listener: (message: MessageValue<Message>) => void
   ): void {
@@ -97,12 +97,12 @@ export class FixedThreadPool<
   }
 
   /** @inheritDoc */
-  public get full (): boolean {
-    return this.workers.length === this.numberOfWorkers
+  protected get full (): boolean {
+    return this.workerNodes.length === this.numberOfWorkers
   }
 
   /** @inheritDoc */
-  public get busy (): boolean {
+  protected get busy (): boolean {
     return this.internalBusy()
   }
 }