Skip to content

DeadlineScheduler Class

Default IDeadlineScheduler (SRS FR-RAW-050): hands out Deadline instances that arm their expiry through a single owning IProtocolActor's event-driven timer queue.

public sealed class DeadlineScheduler : CanKit.Pro.Reliability.IDeadlineScheduler

Inheritance Object → DeadlineScheduler

Implements IDeadlineScheduler

Remarks

Stateless apart from the actor reference: a scheduler is just a factory, and every deadline it creates is independent. All timing state lives in the Deadline and, at the bottom, in the actor's own single-threaded timer list -- so there is no shared mutable state in the scheduler itself to synchronize.

Constructors

DeadlineScheduler(IProtocolActor) Constructor

Creates a scheduler whose deadlines fire on actor's loop.

public DeadlineScheduler(CanKit.Pro.Actor.IProtocolActor actor);

Parameters

actor IProtocolActor

The protocol instance's actor. Reused deliberately (rather than spinning up a private timer thread) so a fired deadline runs single-writer-safe alongside the rest of that instance's state (FR-RAW-020/050).

Methods

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

public CanKit.Pro.Reliability.IDeadline Arm(System.TimeSpan timeout, System.Action onExpired);

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.

Implements Arm(TimeSpan, Action)

Returns

IDeadline
A handle used to complete, re-arm, cancel (IDisposable.Dispose), or inspect the deadline.