- public unshiftTask (task: Task<Data>): number {
- const tasksQueueSize = this.tasksQueue.unshift(task)
- if (
- this.onBackPressure != null &&
- this.hasBackPressure() &&
- !this.onBackPressureStarted
- ) {
- this.onBackPressureStarted = true
- this.onBackPressure(this.info.id as number)
- this.onBackPressureStarted = false
- }
- return tasksQueueSize
- }
-
- /** @inheritdoc */
- public dequeueTask (): Task<Data> | undefined {
- const task = this.tasksQueue.shift()
- if (
- this.onEmptyQueue != null &&
- this.tasksQueue.size === 0 &&
- this.onEmptyQueueCount === 0
- ) {
- this.startOnEmptyQueue().catch(EMPTY_FUNCTION)
- }
- return task
- }
-
- /** @inheritdoc */
- public popTask (): Task<Data> | undefined {
- const task = this.tasksQueue.pop()
- if (
- this.onEmptyQueue != null &&
- this.tasksQueue.size === 0 &&
- this.onEmptyQueueCount === 0
- ) {
- this.startOnEmptyQueue().catch(EMPTY_FUNCTION)
- }
- return task