Obtains a snapshot of the current value of the Ref
, and a setter
for updating the value.
Obtains a snapshot of the current value of the Ref
, and a setter
for updating the value. 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.
Like get but returns an F[Unit]
that can be used cancel the subscription.
Obtains the value of the Ref
, or wait until it has been set
.
Repeatedly invokes tryModify(f)
until it succeeds.
Like modify, but allows to extra b
in single step.
Like modify, but allows to extra b
in single step. *
Runs f1
and f2
simultaneously, but only the winner gets to
set
to this ref
.
Runs f1
and f2
simultaneously, but only the winner gets to
set
to this ref
. The loser continues running but its reference
to this ref is severed, allowing this ref to be garbage collected
if it is no longer referenced by anyone other than the loser.
*Asynchronously* sets a reference.
*Asynchronously* sets a reference. After the returned F[Unit]
is bound,
the task is running in the background. Multiple tasks may be added to a
Ref[A]
.
Satisfies: r.setAsync(fa) flatMap { _ => r.get } == fa
*Asynchronously* sets a reference to a pure value.
*Asynchronously* sets a reference to a pure value.
Satisfies: r.setAsyncPure(a) flatMap { _ => r.get(a) } == pure(a)
*Synchronously* sets a reference.
*Synchronously* sets a reference. The returned value completes evaluating after the reference has been successfully set.
*Synchronously* sets a reference to a pure value.
Like get but if the ref has not been initialized when the timeout is reached, a None
is returned.
Tries modifying the reference once, returning None
if another
concurrent set
or modify
completes between the time
the variable is read and the time it is set.
Like tryModify
but allows to return B
along with change.
Like tryModify
but allows to return B
along with change. *
An asynchronous, concurrent mutable reference.