class AsyncMutex
source · line 6public
public class AsyncMutex public constructor()
A non-reentrant FIFO mutex whose ownership may move between managed threads.
function tryLock
source · line 35public
public fun tryLock(): AsyncMutexGuard?
Acquires only if immediately available, without overtaking queued waiters.
function withLock
source · line 46public
public suspend fun <T> withLock(block: AsyncMutexGuard.() -> T): T
Releases the acquired guard when the ordinary block returns or throws.
type parameter T
source · line 46public
T
parameter block
source · line 46public
block: AsyncMutexGuard.() -> T
constructor constructor
source · line 6public
constructor()
function withLock
source · line 57public
public suspend fun <T> withLock(block: suspend AsyncMutexGuard.() -> T): T
Keeps ownership across suspension, and releases on return, failure or cancellation.
parameter block
source · line 57public
block: suspend AsyncMutexGuard.() -> T
type parameter T
source · line 57public
T
function lock
source · line 12public
public suspend fun lock(): AsyncMutexGuard
Acquires a guard, suspending without blocking the executor while contended.