SignallingRef
Pure holder of a single value of type
and updated in the effect
A
that can be both readand updated in the effect
F
.The update methods have the same semantics as Ref, as well as
propagating changes to
in case of very fast updates).
propagating changes to
discrete
(with a last-update-wins policyin case of very fast updates).
The
function, in the presence of
need looping even without any other writers.
access
method differs slightly from Ref
in that the updatefunction, in the presence of
discrete
, can return false
andneed looping even without any other writers.
- Companion
- object
Value members
Inherited methods
def set(a: A): F[Unit]
Sets the current value to
a
.The returned action completes after the reference has been successfully set.
Satisfies:
r.set(fa) *> r.get == fa
- Inhertied from
- RefSink
def updateAndGet(f: A => A): F[A]
Updates the current value using
f
, and returns the updated value.- Inhertied from
- Ref
def modifyState[B](state: State[A, B]): F[B]
Like tryModifyState but retries the modification until successful.
- Inhertied from
- Ref
def tryUpdate(f: A => A): F[Boolean]
Attempts to modify the current value once, returning
concurrent modification completes between the time the variable is
read and the time it is set.
false
if anotherconcurrent modification completes between the time the variable is
read and the time it is set.
- Inhertied from
- Ref
def update(f: A => A): F[Unit]
Modifies the current value using the supplied update function. If another modification
occurs between the time the current value is read and subsequently updated, the modification
is retried using the new value. Hence,
occurs between the time the current value is read and subsequently updated, the modification
is retried using the new value. Hence,
f
may be invoked multiple times.Satisfies:
r.update(_ => a) == r.set(a)
- Inhertied from
- Ref
Returns a stream of the current value of the signal. An element is always
available -- on each pull, the current value is supplied.
available -- on each pull, the current value is supplied.
- Inhertied from
- Signal
def tryModify[B](f: A => (A, B)): F[Option[B]]
Like
type
successfully and
tryUpdate
but allows the update function to return an output value oftype
B
. The returned action completes with None
if the value is not updatedsuccessfully and
Some(b)
otherwise.- Inhertied from
- Ref
def getAndSet(a: A): F[A]
Replaces the current value with
a
, returning the previous value.- Inhertied from
- Ref
def tryModifyState[B](state: State[A, B]): F[Option[B]]
Update the value of this ref with a state computation.
The current value of this ref is used as the initial state and the computed output state
is stored in this ref after computation completes. If a concurrent modification occurs,
is stored in this ref after computation completes. If a concurrent modification occurs,
None
is returned.- Inhertied from
- Ref
def access: F[(A, A => F[Boolean])]
Obtains a snapshot of the current value, and a setter for updating it.
The setter may noop (in which case
call to
The setter may noop (in which case
false
is returned) if another concurrentcall 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.tryUpdate(f).map(_.isDefined)
- Inhertied from
- Ref
def mapK[G <: ([_$3] =>> Any)](f: FunctionK[F, G])(F: Functor[F]): Ref[G, A]
Modify the context
F
using transformation f
.- Inhertied from
- Ref
def getAndUpdate(f: A => A): F[A]
Updates the current value using
f
and returns the previous value.In case of retries caused by concurrent modifications,
the returned value will be the last one before a successful update.
the returned value will be the last one before a successful update.
- Inhertied from
- Ref
Returns a stream of the updates to this signal.
Updates that are very close together may result in only the last update appearing
in the stream. If you want to be notified about every single update, use
a
in the stream. If you want to be notified about every single update, use
a
Queue
or Channel
instead.- Inhertied from
- Signal