IDeadline Interface¶
A single armed deadline (SRS FR-RAW-050). A deadline starts Pending and resolves
exactly once into one of three terminal outcomes: it <b>expires</b> (its onExpired
callback fired), it is <b>completed</b> (the awaited transition finished in time), or it is
<b>cancelled</b> (disposed).
Implements IDisposable
Remarks¶
The three terminal outcomes are mutually exclusive under normal operation: whichever of the
expiry callback, Complete(), or IDisposable.Dispose reaches the internal state
field first "wins" the transition out of Pending, and the others become no-ops. This
lets a caller (e.g. a UDS client tracking a P2 window) ask "did I complete before the
deadline fired?" via Complete()'s return value.
One case resolves into none of the three: if the owning actor is disposed while the
deadline is still Pending, the actor discards its not-yet-due callbacks, so the
expiry can never fire and all three flags stay false forever — indistinguishable from a
healthy pending deadline. Reporting that state would take a fourth flag (or an event) on
this interface, which existing implementers could not absorb without a break, so it is
documented rather than signalled: tie deadline lifetime to actor lifetime, i.e. resolve
outstanding deadlines with Complete()/IDisposable.Dispose before
disposing the actor they were armed on. Rearm(TimeSpan) is the one operation that does
detect it, because it has to talk to the actor: it throws
ObjectDisposedException and forces the deadline to Cancelled.
Properties¶
IDeadline.IsCancelled Property¶
True once the deadline was cancelled via IDisposable.Dispose before it expired or completed.
Property Value¶
IDeadline.IsCompleted Property¶
True once Complete() won the race, i.e. the awaited transition finished before the timeout.
Property Value¶
IDeadline.IsExpired Property¶
True once the deadline's timeout elapsed and its onExpired callback won the race
to fire.
Property Value¶
Methods¶
IDeadline.Complete() Method¶
Marks a still-Pending deadline as completed, cancelling its pending expiry.
Returns¶
Boolean
True if this call won the race and moved the deadline from Pending to
Completed; false if the deadline had already expired, completed, or been cancelled
(idempotent no-op). The return value is the caller's answer to "did I finish before the
deadline fired?".
IDeadline.Rearm(TimeSpan) Method¶
Extends (or shortens) a still-Pending deadline to a new timeout measured from now,
e.g. an ISO-TP receiver refreshing N_Cr on each consecutive frame.
Parameters¶
timeout TimeSpan
New time until expiry, measured from now. Must be >= TimeSpan.Zero.
Returns¶
Boolean
True if the deadline was still Pending and has been re-armed; false if it had
already expired, completed, or been cancelled (in which case nothing changes).