>
/**
- * Whether the pool is starting.
+ * Whether the pool is starting or not.
*/
private readonly starting: boolean
/**
this.setupHook()
this.starting = true
- while (
- this.workerNodes.reduce(
- (accumulator, workerNode) =>
- !workerNode.info.dynamic ? accumulator + 1 : accumulator,
- 0
- ) < this.numberOfWorkers
- ) {
- this.createAndSetupWorker()
- }
+ this.startPool()
this.starting = false
this.startTimestamp = performance.now()
}
}
+ private startPool (): void {
+ while (
+ this.workerNodes.reduce(
+ (accumulator, workerNode) =>
+ !workerNode.info.dynamic ? accumulator + 1 : accumulator,
+ 0
+ ) < this.numberOfWorkers
+ ) {
+ this.createAndSetupWorker()
+ }
+ }
+
/** @inheritDoc */
public get info (): PoolInfo {
return {
const workerNodeKey = this.getWorkerNodeKey(worker)
const workerInfo = this.getWorkerInfo(workerNodeKey)
workerInfo.ready = false
- if (this.emitter != null) {
- this.emitter.emit(PoolEvents.error, error)
- }
+ this.emitter?.emit(PoolEvents.error, error)
if (this.opts.restartWorkerOnError === true && !this.starting) {
if (workerInfo.dynamic) {
this.createAndSetupDynamicWorker()
const promiseResponse = this.promiseResponseMap.get(message.id as string)
if (promiseResponse != null) {
if (message.taskError != null) {
- if (this.emitter != null) {
- this.emitter.emit(PoolEvents.taskError, message.taskError)
- }
+ this.emitter?.emit(PoolEvents.taskError, message.taskError)
promiseResponse.reject(message.taskError.message)
} else {
promiseResponse.resolve(message.data as Response)