ThroughputDispatcher
此内容尚不支持你的语言。
Defined in: src/Dispatcher.ts:267
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.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ThroughputDispatcher(
throughput?,id?):ThroughputDispatcher
Defined in: src/Dispatcher.ts:285
Parameters
Section titled “Parameters”throughput?
Section titled “throughput?”number = DEFAULT_DISPATCHER_THROUGHPUT
How many queued turns one tick drains: an integer from 1 up, refused otherwise (see assertTurnBudget).
string = 'throughput-dispatcher'
The dispatcher’s id in error reports and metrics.
Returns
Section titled “Returns”ThroughputDispatcher
Properties
Section titled “Properties”
readonlyid:string
Defined in: src/Dispatcher.ts:268
Implementation of
Section titled “Implementation of”onError?
Section titled “onError?”
optionalonError?:DispatcherErrorSink
Defined in: src/Dispatcher.ts:269
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.
Implementation of
Section titled “Implementation of”throughput
Section titled “throughput”
readonlythroughput:number=DEFAULT_DISPATCHER_THROUGHPUT
Defined in: src/Dispatcher.ts:286
How many queued turns one tick drains: an integer from 1 up, refused otherwise (see assertTurnBudget).
Methods
Section titled “Methods”execute()
Section titled “execute()”execute(
task):void
Defined in: src/Dispatcher.ts:298
Schedule a unit of work to be executed asynchronously.
Parameters
Section titled “Parameters”() => void | Promise<void>
Returns
Section titled “Returns”void
