withLock

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

Executes action on the current value while holding the Mutex and returns the result.

Return

the result of action

Parameters

owner

optional owner for the mutex lock

action

the action to execute with the current value as receiver

Type Parameters

V

the return type