ETS-backed counting semaphore.
Summary
Functions
Acquire a semaphore in the default registry.
Acquire a semaphore in the provided registry.
Acquire a semaphore, retrying with backoff until available.
Get the current count for a semaphore.
Return the default registry (anonymous ETS table).
Create a new registry. Use name: :my_table for a named ETS table.
Release a semaphore in the default registry.
Release a semaphore in the provided registry.
Attempt to acquire a semaphore without blocking.
Execute a function while holding a semaphore.
Types
Functions
@spec acquire(name(), pos_integer()) :: boolean()
Acquire a semaphore in the default registry.
@spec acquire(registry(), name(), pos_integer()) :: boolean()
Acquire a semaphore in the provided registry.
@spec acquire_blocking( registry(), name(), pos_integer(), Foundation.Backoff.Policy.t(), keyword() ) :: :ok
Acquire a semaphore, retrying with backoff until available.
@spec count(registry(), name()) :: non_neg_integer()
Get the current count for a semaphore.
@spec default_registry() :: registry()
Return the default registry (anonymous ETS table).
Create a new registry. Use name: :my_table for a named ETS table.
@spec release(name()) :: :ok
Release a semaphore in the default registry.
Release a semaphore in the provided registry.
@spec try_acquire(registry(), name(), pos_integer()) :: boolean()
Attempt to acquire a semaphore without blocking.
@spec with_acquire(registry(), name(), pos_integer(), (-> result)) :: {:ok, result} | {:error, :max} when result: any()
Execute a function while holding a semaphore.