Skip to main content

Module temporal

Module temporal 

Source
Expand description

Temporal operators — time-dependent transforms on reactive streams.

§Operators

  • sample — pure reactive; emits source’s latest value when notifier fires. No timer needed.
  • debounce — emits after ms of quiet (no new upstream DATA).
  • throttle — rate-limits: at most one emission per ms window. Configurable leading / trailing edge.
  • delay — delays each upstream DATA by ms. Multiple in-flight.
  • audit — on first DATA, starts a ms timer; when it fires, emits the latest value. Timer does NOT restart on subsequent DATA within the window.
  • interval — source that emits a monotonic counter every period_ms.
  • timeout — errors if no DATA arrives within ms after subscribe or after the previous DATA.
  • buffer_time — collects upstream DATA into a buffer and flushes as a packed tuple every ms milliseconds.
  • window_time — rotates inner sub-nodes every ms milliseconds; upstream DATA is forwarded to the current window node.

§Architecture

Timer operators (debounce, throttle, delay, audit) spawn a per-operator tokio task that owns all pending state (handles, counters) exclusively. The sync sink callback sends [TemporalCmd] commands; the async task manages timers via tokio::time and calls Core::emit_or_defer / complete_or_defer / error_or_defer when ready. This avoids the double-ownership problem that would arise from tracking pending handles in both the operator’s state mutex and the generic timer substrate.

sample is a pure-reactive producer-pattern node with two subscriptions (source + notifier) and no timer dependency.

All temporal operators require a tokio runtime context at activation time (first subscriber triggers the build closure, which calls tokio::spawn).

Structs§

ThrottleOpts
Options for throttle.

Functions§

audit
On the first upstream DATA in each window, starts a ms timer. When the timer fires, emits the latest value received during the window. Subsequent DATA values within the window update the stored value but do NOT restart the timer.
buffer_time
Collects upstream DATA handles into a buffer and flushes them as a packed tuple every ms milliseconds.
debounce
Emits after delay of quiet — each new upstream DATA resets the timer.
delay
Delays each upstream DATA by ms milliseconds. Multiple values can be in-flight simultaneously, each with its own timer.
interval
Source that emits a monotonically increasing counter (1, 2, 3, …) every period_ms milliseconds. Counter starts at 1 (not 0) because HandleId(0) is the NO_HANDLE sentinel. Resubscribable: counter resets on deactivation + reactivation.
sample
Emits the source’s latest DATA each time notifier delivers DATA.
throttle
Rate-limits upstream emissions to at most one per ms-millisecond window.
timeout
Errors if no upstream DATA arrives within ms milliseconds after subscribe or after the previous DATA. Each DATA resets the timer.
window_time
Rotates sub-node windows every ms milliseconds.