Weighted semaphore with blocking acquire and negative budget allowance.
Summary
Functions
Acquire weight, blocking when budget is negative.
Returns a specification to start this module under a supervisor.
Release weight back to the semaphore.
Start a weighted semaphore with the given max weight.
Attempt to acquire weight without blocking.
Execute fun while holding the requested weight.
Types
@type t() :: pid()
Functions
@spec acquire(t(), non_neg_integer()) :: :ok
Acquire weight, blocking when budget is negative.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec release(t(), non_neg_integer()) :: :ok
Release weight back to the semaphore.
@spec start_link(keyword()) :: GenServer.on_start()
Start a weighted semaphore with the given max weight.
@spec try_acquire(t(), non_neg_integer()) :: :ok | {:error, :unavailable}
Attempt to acquire weight without blocking.
@spec with_acquire(t(), non_neg_integer(), (-> result)) :: result when result: any()
Execute fun while holding the requested weight.