Class/Object

scalaz.zio

Promise

Related Docs: object Promise | package zio

Permalink

final class Promise[E, A] extends AnyVal

A promise represents an asynchronous variable that can be set exactly once, with the ability for an arbitrary number of fibers to suspend (by calling get) and automatically resume when the variable is set.

Promises can be used for building primitive actions whose completions require the coordinated action of multiple fibers, and for building higher-level concurrent or asynchronous structures.

for {
  promise <- Promise.make[Nothing, Int]
  _       <- promise.complete(42).delay(1.second).fork
  value   <- promise.get // Resumes when forked fiber completes promise
} yield value
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Promise
  2. AnyVal
  3. 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 await: IO[E, A]

    Permalink

    Retrieves the value of the promise, suspending the fiber running the action until the result is available.

  6. final def done(io: IO[E, A]): IO[Nothing, Boolean]

    Permalink

    Completes the promise with the specified result.

    Completes the promise with the specified result. If the specified promise has already been completed, the method will produce false.

  7. final def fail(e: E): IO[Nothing, Boolean]

    Permalink

    Fails the promise with the specified error, which will be propagated to all fibers waiting on the value of the promise.

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

    Permalink
    Definition Classes
    AnyVal → Any
  9. final def interrupt: IO[Nothing, Boolean]

    Permalink

    Completes the promise with interruption.

    Completes the promise with interruption. This will interrupt all fibers waiting on the value of the promise.

  10. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  11. final def poll: IO[Nothing, Option[IO[E, A]]]

    Permalink

    Completes immediately this promise and returns optionally it's result.

  12. final def succeed(a: A): IO[Nothing, Boolean]

    Permalink

    Completes the promise with the specified value.

  13. def toString(): String

    Permalink
    Definition Classes
    Any

Inherited from AnyVal

Inherited from Any

Ungrouped