Class/Object

scalaz.zio

Ref

Related Docs: object Ref | package zio

Permalink

final class Ref[A] extends AnyVal with Serializable

A mutable atomic reference for the IO monad. This is the IO equivalent of a volatile var, augmented with atomic operations, which make it useful as a reasonably efficient (if low-level) concurrency primitive.

for {
  ref <- Ref(2)
  v   <- ref.update(_ + 3)
  _   <- putStrLn("Value = " + v) // Value = 5
} yield ()
Linear Supertypes
Serializable, Serializable, AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Ref
  2. Serializable
  3. Serializable
  4. AnyVal
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

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

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

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

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

    Permalink
    Definition Classes
    Any
  5. final def get: IO[Nothing, A]

    Permalink

    Reads the value from the Ref.

  6. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  7. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  8. final def modify[B](f: (A) ⇒ (B, A)): IO[Nothing, B]

    Permalink

    Atomically modifies the Ref with the specified function, which computes a return value for the modification.

    Atomically modifies the Ref with the specified function, which computes a return value for the modification. This is a more powerful version of update.

  9. final def modifySome[B](default: B)(pf: PartialFunction[A, (B, A)]): IO[Nothing, B]

    Permalink

    Atomically modifies the Ref with the specified partial function, which computes a return value for the modification if the function is defined in the current value otherwise it returns a default value.

    Atomically modifies the Ref with the specified partial function, which computes a return value for the modification if the function is defined in the current value otherwise it returns a default value. This is a more powerful version of updateSome.

  10. final def set(a: A): IO[Nothing, Unit]

    Permalink

    Writes a new value to the Ref, with a guarantee of immediate consistency (at some cost to performance).

  11. final def setAsync(a: A): IO[Nothing, Unit]

    Permalink

    Writes a new value to the Ref without providing a guarantee of immediate consistency.

  12. def toString(): String

    Permalink
    Definition Classes
    Any
  13. final def update(f: (A) ⇒ A): IO[Nothing, A]

    Permalink

    Atomically modifies the Ref with the specified function.

    Atomically modifies the Ref with the specified function. This is not implemented in terms of modify purely for performance reasons.

  14. final def updateSome(pf: PartialFunction[A, A]): IO[Nothing, A]

    Permalink

    Atomically modifies the Ref with the specified partial function.

    Atomically modifies the Ref with the specified partial function. if the function is undefined in the current value it returns the old value without changing it.

Inherited from Serializable

Inherited from Serializable

Inherited from AnyVal

Inherited from Any

Ungrouped