Class/Object

cats.effect.concurrent

Ref

Related Docs: object Ref | package concurrent

Permalink

abstract 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 Deferred. For this reason, a Ref is always initialised to a value.

The default implementation is nonblocking and lightweight, consisting essentially of a purely functional wrapper over an AtomicReference.

Source
Ref.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Ref
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Ref()

    Permalink

Abstract Value Members

  1. abstract def access: F[(A, (A) ⇒ F[Boolean])]

    Permalink

    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.tryUpdate(f).map(_.isDefined)

  2. abstract def compareAndSet(expected: A, newValue: A): F[Boolean]

    Permalink

    Sets the value to newValue if the current value is expected.

    Sets the value to newValue if the current value is expected. Note: reference equality is used here.

  3. abstract def get: F[A]

    Permalink

    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.

  4. abstract def getAndSet(a: A): F[A]

    Permalink

    Replaces the current value with a, returning the previous value.

  5. abstract def lazySet(a: A): F[Unit]

    Permalink

    Eventually sets the current value to the a.

    Eventually sets the current value to the a.

    The returned action completes after the reference has been lazily set.

  6. abstract def modify[B](f: (A) ⇒ (A, B)): F[B]

    Permalink

    Like tryModify but does not complete until the update has been successfully made.

  7. abstract def modifyState[B](state: State[A, B]): F[B]

    Permalink

    Like tryModifyState but retries the modification until successful.

  8. abstract def set(a: A): F[Unit]

    Permalink

    Sets the current value to a.

    Sets the current value to a.

    The returned action completes after the reference has been successfully set.

    Satisfies: r.set(fa) *> r.get == fa

  9. abstract def tryModify[B](f: (A) ⇒ (A, B)): F[Option[B]]

    Permalink

    Like tryUpdate but allows the update function to return an output value of type B.

    Like tryUpdate but allows the update function to return an output value of type B. The returned action completes with None if the value is not updated successfully and Some(b) otherwise.

  10. abstract def tryModifyState[B](state: State[A, B]): F[Option[B]]

    Permalink

    Update the value of this ref with a state computation.

    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, None is returned.

  11. abstract def tryUpdate(f: (A) ⇒ A): F[Boolean]

    Permalink

    Attempts to modify the current value once, returning false if another concurrent modification completes between the time the variable is read and the time it is set.

  12. abstract def update(f: (A) ⇒ A): F[Unit]

    Permalink

    Modifies the current value using the supplied update function.

    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, f may be invoked multiple times.

    Satisfies: r.update(_ => a) == r.set(a)

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  16. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped