LemonGateway. EngineLock
(lemon_gateway v0.1.0)
View Source
Mutex lock preventing concurrent engine runs on the same session.
Provides fair FIFO queueing with configurable timeouts. Monitors lock
holders and automatically releases locks when processes die. Periodically
sweeps stale locks that exceed max_lock_age_ms.
Summary
Functions
Acquires the engine lock for the given thread key.
Returns a specification to start this module under a supervisor.
Types
@type thread_key() :: term()
Functions
@spec acquire(thread_key(), non_neg_integer()) :: {:ok, (-> :ok)} | {:error, :timeout}
Acquires the engine lock for the given thread key.
Returns {:ok, release_fn} where release_fn is a zero-arity function
that must be called to release the lock. Returns {:error, :timeout}
if the lock cannot be acquired within timeout_ms.
Returns a specification to start this module under a supervisor.
See Supervisor.