Tests whether this Future has been completed.
Tests whether this Future has been completed.
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. Multiple callbacks may be registered; there is no guarantee that they will be executed in a particular order.
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
Should throw java.util.concurrent.TimeoutException if times out This method should not be called directly.
Should throw java.util.concurrent.TimeoutException if times out This method should not be called directly.
Throws exceptions if cannot produce a T within the specified time This method should not be called directly.
Throws exceptions if cannot produce a T within the specified time This method should not be called directly.
Completes this Promise with the specified result, if not already completed.
Completes this Promise with the specified result, if not already completed.
whether this call completed the Promise
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.
Returns a new Future that will contain the completed result of this Future, and which will invoke the supplied PartialFunction when completed.
Returns a new Future that will contain the completed result of this Future, and which will invoke the supplied PartialFunction when completed.
This allows for establishing order of side-effects.
Future { 5 } andThen { case something => assert(something is awesome) } andThen { case Left(t) => handleProblem(t) case Right(v) => dealWithSuccess(v) }
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
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.
Completes this Promise with the specified result, if not already completed.
Completes this Promise with the specified result, if not already completed.
this
if already completed, this is to aid in debugging of complete-races, use tryComplete to do a conditional complete.
Completes this Promise with the specified other Future, when that Future is completed, unless this Promise has already been completed.
Completes this Promise with the specified other Future, when that Future is completed, unless this Promise has already been completed.
this.
Returns a failure projection of this Future
If this
becomes completed with a failure, that failure will be the success of the returned Future
If this
becomes completed with a result, then the returned future will fail with a NoSuchElementException
Returns a failure projection of this Future
If this
becomes completed with a failure, that failure will be the success of the returned Future
If this
becomes completed with a result, then the returned future will fail with a NoSuchElementException
Completes this Promise with the specified exception, if not already completed.
Completes this Promise with the specified exception, if not already completed.
this
Returns a new Future that will either hold the successful value of this Future, or, it this Future fails, it will hold the result of "that" Future.
Returns a new Future that will either hold the successful value of this Future, or, it this Future fails, it will hold the result of "that" Future.
Returns a new Future that will hold the successful result of this Future if it matches the given predicate, if it doesn't match, the resulting Future will be a failed Future with a MatchError, of if this Future fails, that failure will be propagated to the returned Future
Returns a new Future that will hold the successful result of this Future if it matches the given predicate, if it doesn't match, the resulting Future will be a failed Future with a MatchError, of if this Future fails, that failure will be propagated to the returned Future
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
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
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
Same as onSuccess { case r => f(r) } but is also used in for-comprehensions
Same as onSuccess { case r => f(r) } but is also used in for-comprehensions
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
Returns the Future associated with this Promise
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
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
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 used from Java, to create the Manifest, use: import static akka.japi.Util.manifest; future.mapTo(manifest(MyClass.class));
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 onFailure { case NumberFormatException ⇒ target ! "wrong format" }
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
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 onSuccess { case Foo ⇒ target ! "foo" case Bar ⇒ target ! "bar" }
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
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) recover { case e: ArithmeticException ⇒ 0 } // result: 0 Future(6 / 0) recover { case e: NotFoundException ⇒ 0 } // result: exception Future(6 / 2) recover { case e: ArithmeticException ⇒ 0 } // result: 3
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
Returns a new Future that will, in case this future fails, be completed with the resulting Future of the given PartialFunction, if the given PartialFunction matches the failure of the original Future.
Returns a new Future that will, in case this future fails, be completed with the resulting Future of the given PartialFunction, if the given PartialFunction matches the failure of the original Future.
If the PartialFunction throws, that Throwable will be propagated to the returned Future.
Example:
val f = Future { Int.MaxValue } Future (6 / 0) recoverWith { case e: ArithmeticException => f } // result: Int.MaxValue
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
Completes this Promise with the specified result, if not already completed.
Completes this Promise with the specified result, if not already completed.
this
Used by for-comprehensions
Used by for-comprehensions
Note: the callback function may (and probably will) run in another thread,
and therefore should not refer to any unsynchronized state. In
particular, if using this method from an actor, do not access
the state of the actor from the callback function.
Promise.completeWith
,
PipeableFuture.pipeTo
,
and Future.fallbackTo
are some methods to consider
using when possible, to avoid concurrent callbacks.
a new Future that will contain a tuple containing the successful result of this and that Future. If this or that fail, they will race to complete the returned Future with their failure. The returned Future will not be completed if neither this nor that are completed.
(Since version 2.0.2) Was never officially supported or documented, will be removed in Akka 2.1
Essentially this is the Promise (or write-side) of a Future (read-side).