Single¶
Limits a reaction to a single concurrent execution.
Equivalent to Buffer<1>.
Syntax¶
Behavior¶
Only one instance of the reaction may be active (running or queued) at any time. If a new trigger arrives while the reaction is already in progress, the new task is dropped.
sequenceDiagram
participant S as Scheduler
participant R as Reaction
S->>R: Trigger 1 → executes
S--xR: Trigger 2 → dropped (reaction busy)
S--xR: Trigger 3 → dropped (reaction busy)
R-->>S: Trigger 1 completes
S->>R: Trigger 4 → executes
Example¶
on<Trigger<Frame>, Single>().then([](const Frame& f) {
// Only one instance runs at a time
// If a new Frame arrives while this is processing, it's dropped
process_frame(f);
});
A common use case is preventing work from piling up when processing is slower than the input rate (e.g. frame processing, expensive computations).
Notes¶
Singleis literallyBuffer<1>— it is a typedef/inheritance ofBufferwith size 1.- Dropped tasks are silently discarded; no error or log is emitted.