import { CircularArray } from '../circular-array'
import type { Task } from '../utility-types'
import { DEFAULT_TASK_NAME, getWorkerId, getWorkerType } from '../utils'
import { CircularArray } from '../circular-array'
import type { Task } from '../utility-types'
import { DEFAULT_TASK_NAME, getWorkerId, getWorkerType } from '../utils'
* @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
*/
export class WorkerNode<Worker extends IWorker, Data = unknown>
* @typeParam Data - Type of data sent to the worker. This can only be structured-cloneable data.
*/
export class WorkerNode<Worker extends IWorker, Data = unknown>
implements IWorkerNode<Worker, Data> {
/** @inheritdoc */
public readonly worker: Worker
implements IWorkerNode<Worker, Data> {
/** @inheritdoc */
public readonly worker: Worker
const tasksQueueSize = this.tasksQueue.push(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
const tasksQueueSize = this.tasksQueue.push(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
const tasksQueueSize = this.tasksQueue.unshift(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true
const tasksQueueSize = this.tasksQueue.unshift(task)
if (this.hasBackPressure() && !this.onBackPressureStarted) {
this.onBackPressureStarted = true