Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/poolifier/src/pools/worker.ts>IWorkerNode

Fast and small web worker pool
Latest
interface IWorkerNode
implements EventTarget
import { type IWorkerNode } from "https://deno.land/x/poolifier@v0.3.14/src/pools/worker.ts";

Worker node interface.

Type Parameters

Worker extends IWorker
optional
Data = unknown

Properties

readonly
worker: Worker

Worker.

readonly
info: WorkerInfo

Worker info.

readonly
usage: WorkerUsage

Worker usage statistics.

optional
strategyData: StrategyData

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

readonly
optional
messageChannel: MessageChannel

Message channel (worker thread only).

tasksQueueBackPressureSize: number

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

readonly
tasksQueueSize: () => number

Tasks queue size.

readonly
enqueueTask: (task: Task<Data>) => number

Enqueue task.

readonly
unshiftTask: (task: Task<Data>) => number

Prepends a task to the tasks queue.

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

Dequeue task.

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

Pops a task from the tasks queue.

readonly
clearTasksQueue: () => void

Clears tasks queue.

readonly
hasBackPressure: () => boolean

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

readonly
resetUsage: () => void

Resets usage statistics.

readonly
terminate: () => void

Terminates the worker node.

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

Gets task function worker usage statistics.

readonly
deleteTaskFunctionWorkerUsage: (name: string) => boolean

Deletes task function worker usage statistics.