Interface IWorkerNode<Worker, Data>Internal

Worker node interface.

Type Parameters

  • Worker extends IWorker

    Type of worker.

  • Data = unknown

    Type of data sent to the worker. This can only be structured-cloneable data.

Hierarchy

  • IWorkerNode

Properties

clearTasksQueue: (() => void)

Type declaration

    • (): void
    • Clears tasks queue.

      Returns void

closeChannel: (() => void)

Type declaration

    • (): void
    • Closes communication channel.

      Returns void

dequeueTask: (() => undefined | Task<Data>)

Type declaration

    • (): undefined | Task<Data>
    • Dequeue task.

      Returns undefined | Task<Data>

      The dequeued task.

enqueueTask: ((task) => number)

Type declaration

    • (task): number
    • Enqueue task.

      Parameters

      • task: Task<Data>

        The task to queue.

      Returns number

      The tasks queue size.

getTaskFunctionWorkerUsage: ((name) => undefined | WorkerUsage)

Type declaration

    • (name): undefined | WorkerUsage
    • Gets task function worker usage statistics.

      Parameters

      • name: string

        The task function name.

      Returns undefined | WorkerUsage

      The task function worker usage statistics if the task function worker usage statistics are initialized, undefined otherwise.

hasBackPressure: (() => boolean)

Type declaration

    • (): boolean
    • Whether the worker node has back pressure (i.e. its tasks queue is full).

      Returns boolean

      true if the worker node has back pressure, false otherwise.

Worker info.

messageChannel?: MessageChannel

Message channel (worker_threads only).

onBackPressure?: ((workerId) => void)

Type declaration

    • (workerId): void
    • Callback invoked when worker node tasks queue is back pressured.

      Parameters

      • workerId: number

        The worker id.

      Returns void

onEmptyQueue?: ((workerId) => void)

Type declaration

    • (workerId): void
    • Callback invoked when worker node tasks queue is empty.

      Parameters

      • workerId: number

        The worker id.

      Returns void

popTask: (() => undefined | Task<Data>)

Type declaration

    • (): undefined | Task<Data>
    • Pops a task from the tasks queue.

      Returns undefined | Task<Data>

      The popped task.

resetUsage: (() => void)

Type declaration

    • (): void
    • Resets usage statistics.

      Returns void

tasksQueueBackPressureSize: number

Tasks queue back pressure size. This is the number of tasks that can be enqueued before the worker node has back pressure.

tasksQueueSize: (() => number)

Type declaration

    • (): number
    • Tasks queue size.

      Returns number

      The tasks queue size.

unshiftTask: ((task) => number)

Type declaration

    • (task): number
    • Prepends a task to the tasks queue.

      Parameters

      • task: Task<Data>

        The task to prepend.

      Returns number

      The tasks queue size.

Worker usage statistics.

worker: Worker

Worker.

Generated using TypeDoc