X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fworker-node.ts;h=e79aed0bc3aa68b880d0d265bca4fb2ecf8a9bff;hb=e57eb4d0ea721c4dea66047c431d516f74270453;hp=116fb8448d8435ecb98c5573bb781f258026e589;hpb=fd98bbb90c7202f5dd734c029f3cee2f997aea24;p=poolifier.git diff --git a/src/pools/worker-node.ts b/src/pools/worker-node.ts index 116fb844..e79aed0b 100644 --- a/src/pools/worker-node.ts +++ b/src/pools/worker-node.ts @@ -1,7 +1,7 @@ import { MessageChannel } from 'node:worker_threads' import { CircularArray } from '../circular-array' import type { Task } from '../utility-types' -import { DEFAULT_TASK_NAME, once } from '../utils' +import { DEFAULT_TASK_NAME } from '../utils' import { Deque } from '../deque' import { type IWorker, @@ -87,7 +87,7 @@ implements IWorkerNode { public enqueueTask (task: Task): number { const tasksQueueSize = this.tasksQueue.push(task) if (this.onBackPressure != null && this.hasBackPressure()) { - once(this.onBackPressure, this)(this.info.id as number) + this.onBackPressure(this.info.id as number) } return tasksQueueSize } @@ -96,7 +96,7 @@ implements IWorkerNode { public unshiftTask (task: Task): number { const tasksQueueSize = this.tasksQueue.unshift(task) if (this.onBackPressure != null && this.hasBackPressure()) { - once(this.onBackPressure, this)(this.info.id as number) + this.onBackPressure(this.info.id as number) } return tasksQueueSize } @@ -105,7 +105,7 @@ implements IWorkerNode { public dequeueTask (): Task | undefined { const task = this.tasksQueue.shift() if (this.onEmptyQueue != null && this.tasksQueue.size === 0) { - once(this.onEmptyQueue, this)(this.info.id as number) + this.onEmptyQueue(this.info.id as number) } return task } @@ -114,7 +114,7 @@ implements IWorkerNode { public popTask (): Task | undefined { const task = this.tasksQueue.pop() if (this.onEmptyQueue != null && this.tasksQueue.size === 0) { - once(this.onEmptyQueue, this)(this.info.id as number) + this.onEmptyQueue(this.info.id as number) } return task }