access

abstract suspend fun access(): Pair<A, suspend (A) -> Boolean>(source)

Obtains a snapshot of the current value, and a setter for updating it.

This is useful when you need to execute effects with the original result while still ensuring an atomic update.

The setter will return false if another concurrent call invalidated the snapshot (modified the value). It will return true if setting the value was successful.

Once it has returned false or been used once, a setter never succeeds again.