* @param opts - Options for the pool.
*/
public constructor (
- public readonly numberOfWorkers: number,
- public readonly filePath: string,
- public readonly opts: PoolOptions<Worker>
+ protected readonly numberOfWorkers: number,
+ protected readonly filePath: string,
+ protected readonly opts: PoolOptions<Worker>
) {
if (!this.isMain()) {
throw new Error('Cannot start a pool from a worker!')
}
}
- /** @inheritDoc */
- public abstract get type (): PoolType
-
/** @inheritDoc */
public get info (): PoolInfo {
return {
}
}
+ /**
+ * Pool type.
+ *
+ * If it is `'dynamic'`, it provides the `max` property.
+ */
+ protected abstract get type (): PoolType
+
/**
* Gets the worker type.
*/
*
* 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.
await Promise.all(
this.workerNodes.map(async (workerNode, workerNodeKey) => {
this.flushTasksQueue(workerNodeKey)
+ // FIXME: wait for tasks to be finished
await this.destroyWorker(workerNode.worker)
})
)
) {
// 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<void>)
}
})