← All compilation units

Flyology.Fairness

Description

Provides explicit cooperative yield points for CPU-bound task code.

Example:

Flyology.Fairness.Checkpoint (Budget);

Checkpoint

procedure Checkpoint (Budget : in out Yield_Budget)

Yield when Budget's quantum has elapsed. Otherwise return immediately. Lightweight tasks return to their event loop; native tasks perform the normal Ada delay 0.0 scheduling point. Fairness remains cooperative.

Parameters
Budget

State owned by the calling task

Configure

procedure Configure
  (Budget  : in out Yield_Budget;
   Quantum : Ada.Real_Time.Time_Span := Default_Quantum)

Reset Budget and schedule its first eligible yield Quantum from now. Quantum is elapsed wall-clock time. Checkpoint yields at most once after an overrun, then starts a new quantum.

Parameters
Budget

State owned by the calling task

Quantum

Positive interval between eligible yields

Default_Quantum

Default_Quantum : constant Ada.Real_Time.Time_Span :=
  Ada.Real_Time.Milliseconds (2);

Default elapsed time between eligible cooperative yields.

Yield_Budget

type Yield_Budget is tagged limited private;

Per-task checkpoint state. A budget is not synchronized and must be used by one task at a time.

Yield_Now

procedure Yield_Now

Perform one cooperative scheduling point using delay 0.0.