Mutex
Mutual exclusion for coroutines.
Mutex has two states: locked and unlocked. It is non-reentrant, that is invoking lock even from the same thread/coroutine that currently holds the lock still suspends the invoker.
JVM API note: Memory semantic of the Mutex is similar to synchronized
block on JVM: An unlock operation on a Mutex happens-before every subsequent successful lock on that Mutex. Unsuccessful call to tryLock do not have any memory effects.
Functions
Link copied to clipboard
Unlocks this mutex. Throws IllegalStateException if invoked on a mutex that is not locked or was locked with a different owner token (by identity).