Skip to content

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).

public interface IDeadline : System.IDisposable

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.

bool IsCancelled { get; }

Property Value

Boolean

IDeadline.IsCompleted Property

True once Complete() won the race, i.e. the awaited transition finished before the timeout.

bool IsCompleted { get; }

Property Value

Boolean

IDeadline.IsExpired Property

True once the deadline's timeout elapsed and its onExpired callback won the race to fire.

bool IsExpired { get; }

Property Value

Boolean

Methods

IDeadline.Complete() Method

Marks a still-Pending deadline as completed, cancelling its pending expiry.

bool Complete();

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.

bool Rearm(System.TimeSpan timeout);

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).