+
+ private checkAndEmitFull (): void {
+ if (
+ this.type === PoolType.DYNAMIC &&
+ this.opts.enableEvents === true &&
+ this.full
+ ) {
+ this.emitter?.emit('full')
+ }
+ }
+
+ /**
+ * Gets the given worker tasks usage in the pool.
+ *
+ * @param worker - The worker.
+ * @returns The worker tasks usage.
+ */
+ private getWorkerTasksUsage (worker: Worker): TasksUsage | undefined {
+ const workerKey = this.getWorkerKey(worker)
+ if (workerKey !== -1) {
+ return this.workers[workerKey].tasksUsage
+ }
+ throw new Error('Worker could not be found in the pool')
+ }
+
+ /**
+ * Pushes the given worker in the pool.
+ *
+ * @param worker - The worker.
+ * @param tasksUsage - The worker tasks usage.
+ */
+ private pushWorker (worker: Worker, tasksUsage: TasksUsage): void {
+ this.workers.push({
+ worker,
+ tasksUsage
+ })
+ }
+
+ /**
+ * Sets the given worker in the pool.
+ *
+ * @param workerKey - The worker key.
+ * @param worker - The worker.
+ * @param tasksUsage - The worker tasks usage.
+ */
+ private setWorker (
+ workerKey: number,
+ worker: Worker,
+ tasksUsage: TasksUsage
+ ): void {
+ this.workers[workerKey] = {
+ worker,
+ tasksUsage
+ }
+ }
+
+ /**
+ * Removes the given worker from the pool.
+ *
+ * @param worker - The worker that will be removed.
+ */
+ protected removeWorker (worker: Worker): void {
+ const workerKey = this.getWorkerKey(worker)
+ this.workers.splice(workerKey, 1)
+ this.workerChoiceStrategyContext.remove(workerKey)
+ }