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
- Alphabetic
- By Inheritance
- Promise
- 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
complete(a: A): IO[Nothing, Boolean]
Completes the promise with the specified value.
-
final
def
done(r: ExitResult[E, A]): IO[Nothing, 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
error(e: E): IO[Nothing, Boolean]
Fails the promise with the specified error, which will be propagated to all fibers waiting on the value of the promise.
-
final
def
get: IO[E, A]
Retrieves the value of the promise, suspending the fiber running the action until the result is available.
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
interrupt(t: Throwable, ts: Throwable*): IO[Nothing, Boolean]
Interrupts the promise with the specified throwable(s).
Interrupts the promise with the specified throwable(s). This will interrupt all fibers waiting on the value of the promise.
-
final
def
interrupt: IO[Nothing, Boolean]
Interrupts the promise with no specified reason.
Interrupts the promise with no specified reason. This will interrupt all fibers waiting on the value of the promise.
-
final
def
interrupt0(ts: List[Throwable]): IO[Nothing, Boolean]
Interrupts the promise with the specified list of throwable(s).
Interrupts the promise with the specified list of throwable(s). This will interrupt all fibers waiting on the value of the promise.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
poll: IO[Unit, ExitResult[E, A]]
Retrieves immediately the ExitResult of this promise if done and fails immediately with Unit otherwise
-
def
toString(): String
- Definition Classes
- Any