Description
Idempotently reject new acquisitions and release queued callers. Borrowed shutdown and admission readiness descriptors are signalled. Program_Error is raised when a borrowed wake descriptor cannot be signalled; shutdown remains recorded.
Acquire
entry Acquire (Accepted : out Boolean; Cleanup_Armed : access Boolean := null)
Wait until a permit is available or shutdown has been requested.
Parameters
- Accepted
True when one permit was acquired; False on shutdown
- Cleanup_Armed
Optional caller-owned cleanup obligation. When non-null it must designate False on call. It remains False when Accepted is False and becomes True in the protected action that acquires the permit. The caller must then release or atomically transfer that obligation.
Raised exceptions
- Program_Error
Cleanup_Armed designates True on call, or a pending admission readiness signal cannot be consumed
Acquire_Wait_Source
procedure Acquire_Wait_Source (FD : out Interfaces.C.int; Can_Acquire : out Boolean)
Borrow a descriptor for composing nonblocking Try_Acquire with an interruptible wait. When Can_Acquire is False, FD becomes readable after a permit is released or shutdown starts. When Can_Acquire is True, retry Try_Acquire without waiting and FD is -1. The caller must not read or close FD, and the Gate must outlive the wait.
Parameters
- FD
Borrowed readiness descriptor, or -1 when a retry is ready
- Can_Acquire
Whether Try_Acquire can make progress immediately
Raised exceptions
- Program_Error
Wake descriptor creation fails
Active
function Active return Natural
Return the number of active permits.
Return value
Current active count
Await_Drained
entry Await_Drained
Wait until shutdown has been requested and every permit is released.
Release
procedure Release (Cleanup_Armed : access Boolean := null)
Release one acquired permit. If an Acquire_Wait_Source has been borrowed, releasing the permit also wakes its waiters.
Parameters
- Cleanup_Armed
Optional caller-owned cleanup obligation. When non-null it must designate True on call and becomes False in the protected action that releases the permit, before any fallible wake. It remains False if wake signalling then fails.
Raised exceptions
- Program_Error
Cleanup_Armed designates False on call, no permit is active, or the admission readiness source cannot be signalled. A signalling failure leaves the permit released.
Request_Shutdown
procedure Request_Shutdown
Idempotently reject new acquisitions and release queued callers. Borrowed shutdown and admission readiness descriptors are signalled. Program_Error is raised when a borrowed wake descriptor cannot be signalled; shutdown remains recorded.
Shutdown_Requested
function Shutdown_Requested return Boolean
Report whether shutdown has been requested.
Return value
True after Request_Shutdown
Try_Acquire
procedure Try_Acquire (Result : out Acquire_Result; Cleanup_Armed : access Boolean := null)
Attempt to acquire without waiting.
Parameters
- Result
Permit_Acquired, Gate_Full, or Gate_Closed
- Cleanup_Armed
Optional caller-owned cleanup obligation. When non-null it must designate False on call. It remains False for Gate_Full or Gate_Closed and becomes True in the protected action that returns Permit_Acquired. The caller must then release or atomically transfer that obligation.
Raised exceptions
- Program_Error
Cleanup_Armed designates True on call, or a pending admission readiness signal cannot be consumed
Wait_Source
procedure Wait_Source (FD : out Interfaces.C.int; Already_Requested : out Boolean)
Borrow a readable descriptor that becomes ready on shutdown. This is intended for composing a Gate with task-aware descriptor waits; the caller must not close it and the Gate must outlive the wait.
Parameters
- FD
Borrowed descriptor, or -1 after shutdown
- Already_Requested
Whether shutdown already started
Raised exceptions
- Program_Error
Wake descriptor creation fails
Waiting
function Waiting return Natural
Return the number of callers queued at Acquire.
Return value
Current Acquire entry count