class Mutex
source · line 9public
public class Mutex : Disposable
- Supertype
Disposable
An owned native mutex. Pair lock/unlock on the owning thread or use withLock; dispose only when no operation or held lock remains.
function withLock
source · line 99public
public fun <T> withLock(block: () -> T): T
Runs the block under the mutex and unlocks on both normal and exceptional exit.
type parameter T
source · line 99public
T
parameter block
source · line 99public
block: () -> T
function dispose
source · line 112public
public override fun dispose(): Unit
- Overrides
dispose
Destroys the native mutex when it is no longer in use.
property isDisposed
source · line 15public
public val isDisposed: Boolean
get: public read-only
Whether the native mutex has been released.
getter get
source · line 15public
get(): Boolean
constructor constructor
source · line 17public
constructor()
function tryLock
source · line 67public
public fun tryLock(): Boolean
Attempts acquisition without blocking and returns whether this thread acquired the mutex.
function unlock
source · line 83public
public fun unlock(): Unit
Releases the mutex held by this thread.
function lock
source · line 50public
public fun lock(): Unit
Blocks until this thread acquires the mutex.