X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=122e9fa5c9dbbad12f7eaf01b1db4f0b38ab35e4;hb=1d71a90829622a3541c2530c90b208e9e72ba9ec;hp=76f5bfdc24d47820f9cb2aaaac8ca387a4670a55;hpb=63220255217edbd1d0fd039a0dcb3e141739f43a;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 76f5bfdc..122e9fa5 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -2,8 +2,8 @@ import type { MessageValue, PromiseWorkerResponseWrapper } from '../utility-types' -import { EMPTY_FUNCTION, EMPTY_LITERAL } from '../utils' -import { isKillBehavior, KillBehaviors } from '../worker/worker-options' +import { EMPTY_FUNCTION } from '../utils' +import { KillBehaviors, isKillBehavior } from '../worker/worker-options' import type { PoolOptions } from './pool' import { PoolEmitter } from './pool' import type { IPoolInternal, TasksUsage } from './pool-internal' @@ -105,7 +105,7 @@ export abstract class AbstractPool< this.getWorkerRunningTasks(workerCreated) === 0 ) { // Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime) - void (this.destroyWorker(workerCreated) as Promise) + void this.destroyWorker(workerCreated) } }) return workerCreated @@ -208,7 +208,8 @@ export abstract class AbstractPool< const res = this.internalExecute(worker, this.nextMessageId) this.checkAndEmitBusy() this.sendToWorker(worker, { - data: data ?? (EMPTY_LITERAL as Data), + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + data: data ?? ({} as Data), id: this.nextMessageId }) ++this.nextMessageId @@ -218,7 +219,11 @@ export abstract class AbstractPool< /** {@inheritDoc} */ public async destroy (): Promise { - await Promise.all(this.workers.map(worker => this.destroyWorker(worker))) + await Promise.all( + this.workers.map(async worker => { + await this.destroyWorker(worker) + }) + ) } /**