WorkerPool

class WorkerPool
packages/workers/src/pool.ts:111

Members

constructor

constructor(options: PoolOptions) → WorkerPool
optionsPoolOptions
Undocumented

queuedaccessor

queued() → number

Jobs waiting for a worker.

Beside stats() because the performance overlay samples it every frame and stats() allocates — an object, and an array to count the idle workers.

terminatedaccessor

terminated() → boolean

Whether terminate has run. submit throws its invariant from then on, so a caller that submits on its own schedule asks this first.

cancel

cancel(id: number) → void
idnumber
Undocumented

run

run<Request, Response>(task: TaskDefinition<Request, Response>, payload: Request, transfer: readonly ArrayBufferLike[]) → Promise<Response>
taskTaskDefinition<Request, Response>
Undocumented
payloadRequest
Undocumented
transferreadonly ArrayBufferLike[]
Undocumented

setTimingLevel

setTimingLevel(level: string) → void

Tell every worker how much of itself to describe.

Broadcast on every change rather than read once at spawn, because the level changes mid-session — ir.timing(), the performance panel — and a value fixed at construction would leave the worker tracks empty for the rest of it. WorkerTiming in the protocol package carries the rest of the argument, including the three other reasons a query on the worker's URL does not work.

levelstring
Undocumented

stats

stats() → PoolStats

submit

submit<Request, Response>(task: TaskDefinition<Request, Response>, payload: Request, transfer: readonly ArrayBufferLike[]) → JobHandle<Response>

Submit a job. The handle can be canceled whether or not it has started.

taskTaskDefinition<Request, Response>
Undocumented
payloadRequest
Undocumented
transferreadonly ArrayBufferLike[]
Undocumented

terminate

terminate() → void