setWithLock

inline suspend fun setWithLock(owner: Any? = null, action: (T) -> T): T

Atomically updates the value by applying action to the current value while holding the Mutex.

Return

the new value

Parameters

owner

optional owner for the mutex lock

action

a function that receives the current value and returns the new value