withLock

inline suspend fun <T> Mutex.withLock(owner: Any? = null, action: () -> T): T(source)

Executes the given action under this mutex's lock.

Return

the return value of the action.

Parameters

owner

Optional owner token for debugging. When owner is specified (non-null value) and this mutex is already locked with the same token (same identity), this function throws IllegalStateException.