compareAndSet

fun <T> StateContainer<T>.compareAndSet(expectedState: T, newState: T): Boolean

Conditionally updates the state only if the current state matches the expected state.