final class Ref[F[_], A] extends AnyRef
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 Ref is always initialised to a value.
The implementation is nonblocking and lightweight, consisting essentially of
a purely functional wrapper over an AtomicReference
- Source
- Ref.scala
- Alphabetic
- By Inheritance
- Ref
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Ref[F, A], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
access: F[(A, (A) ⇒ F[Boolean])]
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
falseis returned) if another concurrent call toaccessuses its setter first.Once it has noop'd or been used once, a setter never succeeds again.
Satisfies:
r.access.map(_._1) == r.getr.access.flatMap { case (v, setter) => setter(f(v)) } == r.tryModify(f).map(_.isDefined) -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def ensuring(cond: (Ref[F, A]) ⇒ Boolean, msg: ⇒ Any): Ref[F, A]
- def ensuring(cond: (Ref[F, A]) ⇒ Boolean): Ref[F, A]
- def ensuring(cond: Boolean, msg: ⇒ Any): Ref[F, A]
- def ensuring(cond: Boolean): Ref[F, A]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def formatted(fmtstr: String): String
-
def
get: F[A]
Obtains the current value.
Obtains the current value.
Since
Refis always guaranteed to have a value, the returned action completes immediately after being bound. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
modify(f: (A) ⇒ A): F[Change[A]]
Like
tryModifybut does not complete until the update has been successfully made.Like
tryModifybut does not complete until the update has been successfully made.Satisfies:
r.modify(_ => a).void == r.setSync(a) -
def
modify2[B](f: (A) ⇒ (A, B)): F[(Change[A], B)]
Like
modifybut allows returning aBalong with the update. -
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
setAsync(a: A): F[Unit]
*Asynchronously* sets the current value to the
a*Asynchronously* sets the current value to the
aAfter the returned
F[Unit]is bound, an update will eventually occur, setting the current value toa.Satisfies:
r.setAsync(fa) == async.fork(r.setSync(a))but it's significantly faster. -
def
setSync(a: A): F[Unit]
*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 -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tryModify(f: (A) ⇒ A): F[Option[Change[A]]]
Attempts to modify the current value once, returning
Noneif another concurrent modification completes between the time the variable is read and the time it is set. -
def
tryModify2[B](f: (A) ⇒ (A, B)): F[Option[(Change[A], B)]]
Like
tryModifybut allows returning aBalong with the update. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def →[B](y: B): (Ref[F, A], B)