Obtains a snapshot of the current value, and a setter for updating it.
Obtains a snapshot of the current value, and a setter for updating it.
The setter may noop (in which case false is returned) if another concurrent
call to access uses its setter first.
Once it has noop'd or been used once, a setter never succeeds again.
Satisfies:
r.access.map(_._1) == r.get
r.access.flatMap { case (v, setter) => setter(f(v)) } == r.tryModify(f).map(_.isDefined)
Obtains the current value.
Obtains the current value.
Since Ref is always guaranteed to have a value, the returned action
completes immediately after being bound.
Like tryModify but does not complete until the update has been successfully made.
Like tryModify but does not complete until the update has been successfully made.
Satisfies:
r.modify(_ => a).void == r.setSync(a)
Like modify but allows returning a B along with the update.
*Asynchronously* sets the current value to the a
*Asynchronously* sets the current value to the a
After the returned F[Unit] is bound, an update will eventually occur,
setting the current value to a.
Satisfies:
r.setAsync(fa) == async.fork(r.setSync(a))
but it's significantly faster.
*Synchronously* sets the current value to a.
*Synchronously* sets the current value to a.
The returned action completes after the reference has been successfully set.
Satisfies:
r.setSync(fa) *> r.get == fa
Attempts to modify the current value once, returning None if another
concurrent modification completes between the time the variable is
read and the time it is set.
Like tryModify but allows returning a B along with the update.
An asynchronous, concurrent mutable reference.
Provides safe concurrent access and modification of its content, but no functionality for synchronisation, which is instead handled by Promise. For this reason, a
Refis always initialised to a value.The implementation is nonblocking and lightweight, consisting essentially of a purely functional wrapper over an
AtomicReference