IDeadlineScheduler Interface¶
A reusable, actor-driven timeout primitive (SRS FR-RAW-050). Protocol layers (ISO-TP N_Bs/
N_Cr, J1939 timeouts, UDS P2/P2*, CANopen SDO, ...) arm a IDeadline for a
time-bounded state transition and are notified via onExpired when the transition did
not complete in time.
Derived
↳ DeadlineScheduler
Remarks¶
This directly addresses the deep-code-review finding "Deadlines werden gepflegt, aber nie geprüft" (Review §1.1 Punkt 10): a deadline scheduled here is composed on top of the owning IProtocolActor's own event-driven timer queue (Schedule(TimeSpan, Action)), so its expiry is guaranteed to actually fire and be checked on the actor's loop -- it can never sit as inert data that is written but never re-examined. Because every protocol instance already runs on a IProtocolActor (FR-RAW-020), this is deliberately not an independent standalone timer with its own thread; reusing the actor's loop is what keeps the fired callback single-writer-safe against the rest of the instance's state.
Methods¶
IDeadlineScheduler.Arm(TimeSpan, Action) Method¶
Arms a new deadline that will invoke onExpired on the owning actor's loop once timeout has elapsed, unless it is completed or cancelled first.
Parameters¶
timeout TimeSpan
Time until expiry. Must be >= TimeSpan.Zero; a zero timeout fires on the next loop iteration.
onExpired Action
Invoked exactly once, on the actor's loop, if and only if the deadline expires before it is completed or cancelled. Any exception it throws propagates out of the actor's Schedule(TimeSpan, Action) callback and is surfaced through the actor's own BackgroundExceptionOccurred channel (FR-RAW-023) -- there is deliberately no second exception channel here.
Returns¶
IDeadline
A handle used to complete, re-arm, cancel (IDisposable.Dispose), or inspect the deadline.