final class Promise[E, A] extends AnyVal with Serializable
A promise represents an asynchronous variable, of zio.IO type, that can
be set exactly once, with the ability for an arbitrary number of fibers to
suspend (by calling await) 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.succeed(42).delay(1.second).fork value <- promise.await // Resumes when forked fiber completes promise } yield value
- Alphabetic
- By Inheritance
- Promise
- Serializable
- Serializable
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
final
def
await: IO[E, A]
Retrieves the value of the promise, suspending the fiber running the action until the result is available.
-
final
def
complete(io: IO[E, A]): UIO[Boolean]
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.
-
final
def
die(e: Throwable): UIO[Boolean]
Kills the promise with the specified error, which will be propagated to all fibers waiting on the value of the promise.
-
final
def
done(e: Exit[E, A]): UIO[Boolean]
Exits the promise with the specified exit, which will be propagated to all fibers waiting on the value of the promise.
-
final
def
fail(e: E): UIO[Boolean]
Fails the promise with the specified error, which will be propagated to all fibers waiting on the value of the promise.
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
halt(e: Cause[E]): UIO[Boolean]
Halts the promise with the specified cause, which will be propagated to all fibers waiting on the value of the promise.
-
final
def
interrupt: UIO[Boolean]
Completes the promise with interruption.
Completes the promise with interruption. This will interrupt all fibers waiting on the value of the promise.
-
final
def
isDone: UIO[Boolean]
Checks for completion of this Promise.
Checks for completion of this Promise. Produces true if this promise has already been completed with a value or an error and false otherwise.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
poll: UIO[Option[IO[E, A]]]
Completes immediately this promise and returns optionally it's result.
-
final
def
succeed(a: A): UIO[Boolean]
Completes the promise with the specified value.
-
def
toString(): String
- Definition Classes
- Any
Deprecated Value Members
-
final
def
done(io: IO[E, A]): UIO[Boolean]
Alias for Promise.complete
Alias for Promise.complete
- Annotations
- @deprecated
- Deprecated
(Since version 1.0.0) use Promise.complete