← All compilation units

Flyology.Capacity

Description

Bounds concurrent work without owning or creating tasks.

A Gate admits at most Capacity holders. Waiting on Acquire uses ordinary Ada protected-entry semantics, so lightweight tasks suspend cooperatively while native tasks block through GNARL. Shutdown is terminal: it rejects new acquisitions, releases queued callers, and permits existing holders to drain.

Acquire_Result

type Acquire_Result is (Permit_Acquired, Gate_Full, Gate_Closed, Acquire_Timed_Out);

Result of a nonblocking or timed acquisition.

Enumeration literals
Permit_Acquired

One permit is now held by the caller

Gate_Full

A nonblocking attempt found no capacity

Gate_Closed

Shutdown rejected the acquisition

Acquire_Timed_Out

A timed attempt reached its deadline

Timed_Acquire

procedure Timed_Acquire
  (Item          : in out Gate;
   Timeout       : Duration;
   Result        : out Acquire_Result;
   Cleanup_Armed : access Boolean := null)

Acquire within one relative deadline. Negative Timeout waits indefinitely and zero is an immediate attempt. Once the protected entry is accepted, acquisition wins over a simultaneous deadline.

Parameters
Item

Gate from which to acquire one permit

Timeout

Deadline interval in seconds

Result

Permit_Acquired, Gate_Closed, or Acquire_Timed_Out

Cleanup_Armed

Optional caller-owned cleanup obligation. When non-null it must designate False on call. It remains False for Gate_Closed or Acquire_Timed_Out and becomes True in the protected action that acquires the permit, so an abort after that action still leaves the caller's controlled guard responsible for the permit. The caller must then release or atomically transfer that obligation. Result is not written when the caller is aborted, so an abort-safe caller must treat this obligation, not Result, as authoritative.

Raised exceptions
Program_Error

Cleanup_Armed designates True on call, or a pending admission readiness signal cannot be consumed