Class/Object

zio.concurrent

MVar

Related Docs: object MVar | package concurrent

Permalink

final class MVar[A] extends AnyRef

An MVar[A] is a mutable location that is either empty or contains a value of type A. It has two fundamental operations: put which fills an MVar if it is empty and blocks otherwise, and take which empties an MVar if it is full and blocks otherwise. They can be used in multiple different ways:

They were introduced in the paper "Concurrent Haskell" by Simon Peyton Jones, Andrew Gordon and Sigbjorn Finne.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MVar
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

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. def isEmpty: UIO[Boolean]

    Permalink

    Check whether the MVar is empty.

    Check whether the MVar is empty.

    Notice that the boolean value returned is just a snapshot of the state of the MVar. By the time you get to react on its result, the MVar may have been filled (or emptied) - so be extremely careful when using this operation. Use tryTake instead if possible.

  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. def modify[B](f: (A) ⇒ (B, A)): UIO[B]

    Permalink

    A slight variation on update that allows a value to be returned (b) in addition to the modified value of the MVar.

  14. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  17. def put(x: A): UIO[Unit]

    Permalink

    Put a value into an MVar.

    Put a value into an MVar. If the MVar is currently full, put will wait until it becomes empty.

  18. def read: UIO[A]

    Permalink

    Atomically read the contents of an MVar.

    Atomically read the contents of an MVar. If the MVar is currently empty, read will wait until it is full. read is guaranteed to receive the next put.

  19. def swap(x: A): UIO[A]

    Permalink

    Take a value from an MVar, put a new value into the MVar and return the value taken.

  20. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  21. def take: UIO[A]

    Permalink

    Return the contents of the MVar.

    Return the contents of the MVar. If the MVar is currently empty, take will wait until it is full. After a take, the MVar is left empty.

  22. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  23. def tryPut(x: A): UIO[Boolean]

    Permalink

    A non-blocking version of put.

    A non-blocking version of put. The tryPut function attempts to put the value x into the MVar, returning true if it was successful, or false otherwise.

  24. def tryRead: UIO[Option[A]]

    Permalink

    A non-blocking version of read.

    A non-blocking version of read. The tryRead function returns immediately, with None if the MVar was empty, or Some(x) if the MVar was full with contents x.

  25. def tryTake: UIO[Option[A]]

    Permalink

    A non-blocking version of take.

    A non-blocking version of take. The tryTake action returns immediately, with None if the MVar was empty, or Some(x) if the MVar was full with contents x. After tryTake, the MVar is left empty.

  26. def update(f: (A) ⇒ A): UIO[Unit]

    Permalink

    Replaces the contents of an MVar with the result of f(a).

  27. final def wait(): Unit

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped