Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
type WorkerUsage
} from './worker'
type WorkerUsage
} from './worker'
+type EmptyQueueCallback = (workerId: number) => void
+type BackPressureCallback = EmptyQueueCallback
+
/** @inheritdoc */
public tasksQueueBackPressureSize: number
/** @inheritdoc */
/** @inheritdoc */
public tasksQueueBackPressureSize: number
/** @inheritdoc */
- public onBackPressure?: (workerId: number) => void
+ public onBackPressure?: BackPressureCallback
- public onEmptyQueue?: (workerId: number) => void
+ public onEmptyQueue?: EmptyQueueCallback
private readonly tasksQueue: Deque<Task<Data>>
private onEmptyQueueCount: number
private readonly taskFunctionsUsage: Map<string, WorkerUsage>
private readonly tasksQueue: Deque<Task<Data>>
private onEmptyQueueCount: number
private readonly taskFunctionsUsage: Map<string, WorkerUsage>
this.onEmptyQueueCount = 0
return
}
this.onEmptyQueueCount = 0
return
}
- (this.onEmptyQueue as (workerId: number) => void)(this.info.id as number)
+ (this.onEmptyQueue as EmptyQueueCallback)(this.info.id as number)
++this.onEmptyQueueCount
await sleep(exponentialDelay(this.onEmptyQueueCount))
await this.startOnEmptyQueue()
++this.onEmptyQueueCount
await sleep(exponentialDelay(this.onEmptyQueueCount))
await this.startOnEmptyQueue()