For use only within a Future.
For use only within a Future.flow block or another compatible Delimited Continuations reset block.
Returns the result of this Future without blocking, by suspending execution and storing it as a continuation until the result is available.
If this Future is untyped (a Future[Nothing]), a type parameter must be explicitly provided or execution will fail. The normal result of getting a Future from an ActorRef using ? will return an untyped Future.
Await completion of this Future and return its value if it conforms to A's erased type.
Await completion of this Future and return its value if it conforms to A's erased type. Will throw a ClassCastException if the value does not conform, or any exception the Future was completed with. Will return None in case of a timeout.
Await completion of this Future and return its value if it conforms to A's erased type, None otherwise.
Await completion of this Future and return its value if it conforms to A's erased type, None otherwise. Will throw any exception the Future was completed with. Will return None in case of a timeout.
Blocks the current thread until the Future has been completed or the timeout has expired.
Blocks the current thread until the Future has been completed or the timeout has expired. In the case of the timeout expiring a FutureTimeoutException will be thrown.
Blocks the current thread until the Future has been completed or the
timeout has expired, additionally bounding the waiting period according to
the atMost
parameter.
Blocks the current thread until the Future has been completed or the
timeout has expired, additionally bounding the waiting period according to
the atMost
parameter. The timeout will be the lesser value of
'atMost' and the timeout supplied at the constructuion of this Future. In
the case of the timeout expiring a FutureTimeoutException will be thrown.
Other callers of this method are not affected by the additional bound
imposed by atMost
.
Completes this Future with the specified result, if not already completed.
Completes this Future with the specified result, if not already completed.
this
Completes this Future with the specified other Future, when that Future is completed, unless this Future has already been completed.
Completes this Future with the specified other Future, when that Future is completed, unless this Future has already been completed.
this.
Completes this Future with the specified exception, if not already completed.
Completes this Future with the specified exception, if not already completed.
this
Completes this Future with the specified result, if not already completed.
Completes this Future with the specified result, if not already completed.
this
Returns the contained exception of this Future if it exists.
Returns the contained exception of this Future if it exists.
Creates a new Future by applying a function to the successful result of this Future, and returns the result of the function as the new Future.
Creates a new Future by applying a function to the successful result of this Future, and returns the result of the function as the new Future. If this Future is completed with an exception then the new Future will also contain this exception. Example:
val future1 = for { a: Int <- actor ? "Hello" // returns 5 b: String <- actor ? a // returns "10" c: String <- actor ? 7 // returns "14" } yield b + "-" + c
Blocks awaiting completion of this Future, then returns the resulting value, or throws the completed exception
Blocks awaiting completion of this Future, then returns the resulting value, or throws the completed exception
Scala & Java API
throws FutureTimeoutException if this Future times out when waiting for completion
Tests whether this Future has been completed.
Tests whether this Future has been completed.
Tests whether this Future's timeout has expired.
Tests whether this Future's timeout has expired.
Note that an expired Future may still contain a value, or it may be completed with a value.
Creates a new Future by applying a function to the successful result of this Future.
Creates a new Future by applying a function to the successful result of this Future. If this Future is completed with an exception then the new Future will also contain this exception. Example:
val future1 = for { a: Int <- actor ? "Hello" // returns 5 b: String <- actor ? a // returns "10" c: String <- actor ? 7 // returns "14" } yield b + "-" + c
Creates a new Future[A] which is completed with this Future's result if that conforms to A's erased type or a ClassCastException otherwise.
Creates a new Future[A] which is completed with this Future's result if that conforms to A's erased type or a ClassCastException otherwise.
When this Future is completed, apply the provided function to the Future.
When this Future is completed, apply the provided function to the Future. If the Future has already been completed, this will apply immediately. Will not be called in case of a timeout, which also holds if corresponding Promise is attempted to complete after expiry. Multiple callbacks may be registered; there is no guarantee that they will be executed in a particular order.
When the future is completed with an exception, apply the provided PartialFunction to the exception.
When the future is completed with an exception, apply the provided
PartialFunction to the exception. See onComplete
for more details.
future onException { case NumberFormatException ⇒ target ! "wrong format" }
When the future is completed with a valid result, apply the provided PartialFunction to the result.
When the future is completed with a valid result, apply the provided
PartialFunction to the result. See onComplete
for more details.
future onResult { case Foo ⇒ target ! "foo" case Bar ⇒ target ! "bar" }
Registers a function that will be executed when this Future times out.
Registers a function that will be executed when this Future times out.
future onTimeout { f => doSomethingOnTimeout(f) }
Creates a new Future that will handle any matching Throwable that this Future might contain.
Creates a new Future that will handle any matching Throwable that this Future might contain. If there is no match, or if this Future contains a valid result then the new Future will contain the same. Example:
Future(6 / 0) failure { case e: ArithmeticException ⇒ 0 } // result: 0 Future(6 / 0) failure { case e: NotFoundException ⇒ 0 } // result: exception Future(6 / 2) failure { case e: ArithmeticException ⇒ 0 } // result: 3
Returns the successful result of this Future if it exists.
Returns the successful result of this Future if it exists.
Returns the current result, throws the exception is one has been raised, else returns None
Returns the current result, throws the exception is one has been raised, else returns None
This Future's timeout in nanoseconds.
This Future's timeout in nanoseconds.
The contained value of this Future.
The contained value of this Future. Before this Future is completed the value will be None. After completion the value will be Some(Right(t)) if it contains a valid result, or Some(Left(error)) if it contains an exception.
Creates a new Future by applying a PartialFunction to the successful result of this Future if a match is found, or else return a MatchError.
Creates a new Future by applying a PartialFunction to the successful result of this Future if a match is found, or else return a MatchError. If this Future is completed with an exception then the new Future will also contain this exception. Example:
val future1 = for { a <- actor ? Req("Hello") collect { case Res(x: Int) ⇒ x } b <- actor ? Req(a) collect { case Res(x: String) ⇒ x } c <- actor ? Req(7) collect { case Res(x: String) ⇒ x } } yield b + "-" + c
No longer needed, use 'map' instead. Removed in 2.0
Creates a new Future that will handle any matching Throwable that this Future might contain.
Creates a new Future that will handle any matching Throwable that this Future might contain. If there is no match, or if this Future contains a valid result then the new Future will contain the same. Example:
Future(6 / 0) failure { case e: ArithmeticException ⇒ 0 } // result: 0 Future(6 / 0) failure { case e: NotFoundException ⇒ 0 } // result: exception Future(6 / 2) failure { case e: ArithmeticException ⇒ 0 } // result: 3
will be replaced by recover
When the future is completed with a valid result, apply the provided PartialFunction to the result.
When the future is completed with a valid result, apply the provided
PartialFunction to the result. See onComplete
for more details.
future receive { case Foo ⇒ target ! "foo" case Bar ⇒ target ! "bar" }
Use onResult
instead, will be removed in the future
The default concrete Future implementation.