Unlimited

The budget that grants everything at once.

Stable Core. Final, stateless and shared; usable without the opt-in. Ignores signals and close; flush succeeds; utilisation is empty (no windows, no pause, nothing waiting); it checks its arguments as the real budget does, and a cancelled caller gets its CancellationException. toString() is CallBudget.Unlimited.

Functions

Link copied to clipboard
open suspend override fun acquire(cost: Int, lane: Lane, maxWait: Duration): Result<Permit>

Charges cost units to lane now, or once a slot within maxWait comes (contract points 1 to 5).

Link copied to clipboard
open override fun close()

Marks the budget closed (contract point 5). Idempotent, non-suspending, does not throw. The default does nothing.

Link copied to clipboard
open suspend fun flush(): Result<Unit>

Writes the exact counts to the store (contract point 8). The default succeeds, as a budget without a store has nothing to write.

Link copied to clipboard
open override fun toString(): String

Returns the fixed text CallBudget.Unlimited, for diagnostics and logs.

Link copied to clipboard
open suspend override fun utilisation(): BudgetUtilisation

Reads the budget (contract point 7).

Link copied to clipboard
suspend fun <T> CallBudget.withPermit(cost: Int, lane: Lane, maxWait: Duration, block: suspend (Permit) -> Result<T>): Result<T>

Acquires a permit, runs block with it and completes the permit as spent (no signals) in a finally unless the block completed or released it. An exception the block throws propagates after the permit is completed; a refused or closed acquire is returned as the failure and block does not run.