arrow-fx-coroutines / arrow.fx.coroutines / Atomic / access

access

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

Obtain 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.

Do you like Arrow?

Arrow Org
<