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

  • EventTarget
    • IWorkerNode

Properties

clearTasksQueue: (() => void)

Type declaration

    • (): void
    • Clears tasks queue.

      Returns void

closeChannel: (() => void)

Type declaration

    • (): void
    • Closes communication channel.

      Returns void

deleteTaskFunctionWorkerUsage: ((name) => boolean)

Type declaration

    • (name): boolean
    • Deletes task function worker usage statistics.

      Parameters

      • name: string

        The task function name.

      Returns boolean

      true if the task function worker usage statistics were deleted, false otherwise.

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).

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

strategyData?: StrategyData

Worker choice strategy data. This is used to store data that is specific to the worker choice strategy.

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.

Methods

  • Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

    The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

    When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

    When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in ยง 2.8 Observing event listeners.

    When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

    If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

    The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

    MDN Reference

    Parameters

    • event: Event

    Returns boolean

  • Removes the event listener in target's event listener list with the same type, callback, and options.

    MDN Reference

    Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

Generated using TypeDoc