Skip to content
English

ThroughputDispatcher

Defined in: src/Dispatcher.ts:218

Processes up to throughput queued units synchronously before yielding.

A unit is one actor’s turn, not one message, and the queue holds units from many actors — so this batches across actors. The distinction is not pedantry: a cell may have at most one unit queued at a time (ActorCell.schedule returns early while it is already processing), so pointing a ThroughputDispatcher at a single actor via ActorOptions.withDispatcher gives a drain of exactly one unit per tick and no batching whatsoever. The per-actor batch is a separate knob — ActorOptions.withThroughput / actor-ts.actor.throughput (#409) — and it is the one that amortises the scheduling round trip for a single busy actor.

Reach for this one when many actors exchange small messages and the per-tick scheduling overhead across them is what costs; reach for the per-actor budget when one actor is the bottleneck. Either way a high value starves the event loop, since nothing else runs until the drain yields.

new ThroughputDispatcher(throughput?, id?): ThroughputDispatcher

Defined in: src/Dispatcher.ts:231

number = DEFAULT_DISPATCHER_THROUGHPUT

string = 'throughput-dispatcher'

ThroughputDispatcher

readonly id: string

Defined in: src/Dispatcher.ts:219

Dispatcher.id


optional onError?: DispatcherErrorSink

Defined in: src/Dispatcher.ts:220

Where a unit of work that threw is reported. Optional so a third-party dispatcher stays a two-member implementation: an unset sink falls back to console.error, which is what every dispatcher did before the slot existed.

ActorSystem fills it in with ??=, so a sink the owner set deliberately survives being handed to a system.

Dispatcher.onError


readonly throughput: number = DEFAULT_DISPATCHER_THROUGHPUT

Defined in: src/Dispatcher.ts:232

execute(task): void

Defined in: src/Dispatcher.ts:238

Schedule a unit of work to be executed asynchronously.

() => void | Promise<void>

void

Dispatcher.execute