Register a FutureEventListener to be invoked when the computation completes.
Register a FutureEventListener to be invoked when the computation completes. This method is typically used by Java programs because it avoids the use of small Function objects.
this should be used for side-effects
transformedBy for a Java friendly way to produce
a new Future
from the result of a computation.
respond for a Scala API.
Sequentially compose this
with f
.
Returns a new Future that fails if it is not satisfied before the given time.
Returns a new Future that fails if it is not satisfied before the given time.
Note: On timeout, the underlying future is not interrupted.
Note: Interrupting a returned future would not prevent it from being satisfied with a given exception (when the time comes).
to run timeout on.
indicates when to stop waiting for the result to be available.
exception to throw.
Returns a new Future that fails if it is not satisfied before the given time.
Returns a new Future that fails if it is not satisfied before the given time.
Note: On timeout, the underlying future is not interrupted.
Returns a new Future that fails if it is not satisfied before the given time.
Returns a new Future that fails if it is not satisfied before the given time.
Same as the other by
, but with an implicit timer. Sometimes this is more convenient.
Note: On timeout, the underlying future is not interrupted.
Delay the completion of this Future for at least howlong
from now.
Delay the completion of this Future for at least howlong
from now.
Note: Interrupting a returned future would not prevent it from becoming this future (when the time comes).
Invoked regardless of whether the computation completed successfully or unsuccessfully.
Invoked regardless of whether the computation completed successfully or unsuccessfully. Implemented in terms of respond so that subclasses control evaluation order. Returns a chained Future.
The returned Future
will be satisfied when this,
the original future, is done.
the side-effect to apply when the computation completes.
If this, the original future, succeeds, run f
on the result.
If this, the original future, succeeds, run f
on the result.
The returned result is a Future that is satisfied when the original future
and the callback, f
, are done.
If the original future fails, this one will also fail, without executing f
and preserving the failed computation of this
.
Converts a Future[Future[B]]
into a Future[B]
.
Converts a Future[Future[B]]
into a Future[B]
.
Invoke the callback only if the Future returns successfully.
If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.
If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.
The returned result is a Future
that is satisfied when the original
future and the callback, rescueException
, are done.
This is the equivalent of map for failed computations.
Makes a derivative Future
which will be satisfied with the result
of the parent.
Makes a derivative Future
which will be satisfied with the result
of the parent. However, if it's interrupted, it will detach from
the parent Future
, satisfy itself with the exception raised to
it, and won't propagate the interruption back to the parent
Future
.
This is useful for when a Future
is shared between many contexts,
where it may not be useful to discard the underlying computation
if just one context is no longer interested in the result. In
particular, this is different from Future.masked in that it will
prevent memory leaks if the parent Future will never be
satisfied, because closures that are attached to this derivative
Future
will not be held onto by the killer Future
.
Is the result of the Future available yet?
Is the result of the Future available yet?
Checks whether a Unit-typed Future is done.
Checks whether a Unit-typed Future is done. By convention, futures of type Future[Unit] are used for signalling.
Is this Awaitable ready? In other words: would calling Awaitable.ready block?
Is this Awaitable ready? In other words: would calling Awaitable.ready block?
Joins this future with a given other
future into a Future[(A, B)]
(future of a Tuple2
).
Joins this future with a given other
future into a Future[(A, B)]
(future of a Tuple2
). If this or other
future fails, the returned Future
is immediately satisfied by that failure.
Joins this future with a given other
future and applies fn
to its result.
Joins this future with a given other
future and applies fn
to its result.
If this or other
future fails, the returned Future
is immediately satisfied
by that failure.
Before (using join):
val ab = a.join(b).map { case (a, b) => Foo(a, b) }
After (using joinWith):
val ab = a.joinWith(b)(Foo.apply)
Returns the result of the computation as a Future[Try[A]]
.
Returns the result of the computation as a Future[Try[A]]
.
Lowers a Future[Try[T]]
into a Future[T]
.
Lowers a Future[Try[T]]
into a Future[T]
.
If this, the original future, succeeds, run f
on the result.
If this, the original future, succeeds, run f
on the result.
The returned result is a Future that is satisfied when the original future
and the callback, f
, are done.
If the original future fails, this one will also fail, without executing f
and preserving the failed computation of this
.
Returns an identical future except that it ignores interrupts which match a predicate
Returns an identical future except that it ignores interrupts which match a predicate
Returns an identical future that ignores all interrupts
Returns an identical future that ignores all interrupts
Invoke the function on the error, if the computation was unsuccessful.
Invoke the function on the error, if the computation was
unsuccessful. Returns a chained Future as in respond
.
chained Future
if fn
is a PartialFunction
and the input is not defined for a given
Throwable, the resulting MatchError
will propagate to the current
Monitor
. This will happen if you use a construct such as
future.onFailure { case NonFatal(e) => ... }
when the Throwable
is "fatal".
this should be used for side-effects.
handle and rescue to produce a new Future
from the result of
the computation.
Invoke the function on the result, if the computation was successful.
A synonym for select: Choose the first Future
to be satisfied.
Polls for an available result.
Send updates from this Future to the other.
Send updates from this Future to the other.
other
must not yet be satisfied at the time of the call.
After this call, nobody else should satisfy other
.
using proxyTo
will mask interrupts to this future, and it's
the user's responsibility to set an interrupt handler on other
to raise on f. In some cases, using
com.twitter.util.Promise.become may be more appropriate.
Raise the given throwable as an interrupt.
Raise the given throwable as an interrupt. Interrupts are
one-shot and latest-interrupt wins. That is, the last interrupt
to have been raised is delivered exactly once to the Promise
responsible for making progress on the future (multiple such
promises may be involved in flatMap
chains).
Raising an interrupt does not alter the externally observable state of the Future. They are used to signal to the producer of the future's value that the result is no longer desired (for whatever reason given in the passed Throwable).
Returns a new Future that fails if this Future does not return in time.
Returns a new Future that fails if this Future does not return in time.
Note: On timeout, the underlying future is interrupted.
Returns a new Future that fails if this Future does not return in time.
Returns a new Future that fails if this Future does not return in time.
Same as the other raiseWithin
, but with an implicit timer. Sometimes this is more convenient.
Note: On timeout, the underlying future is interrupted.
Returns a new Future that fails if this Future does not return in time.
Returns a new Future that fails if this Future does not return in time.
Same as the other raiseWithin
, but with an implicit timer. Sometimes this is more convenient.
Note: On timeout, the underlying future is interrupted.
Support for Await.ready
.
If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.
If this, the original future, results in an exceptional computation,
rescueException
may convert the failure into a new result.
The returned result is a Future
that is satisfied when the original
future and the callback, rescueException
, are done.
This is the equivalent of flatMap for failed computations.
When the computation completes, invoke the given callback function.
When the computation completes, invoke the given callback function.
The returned Future
will be satisfied when this,
the original future, is done.
This method is most useful for very generic code (like libraries). Otherwise, it is a best practice to use one of the alternatives (onSuccess, onFailure, etc.).
the side-effect to apply when the computation completes.
The value of the input to k
will be the result of the
computation to this future.
a chained Future[A]
this should be used for side-effects.
addEventListener for a Java friendly API.
ensure if you are not interested in the result of the computation.
transform to produce a new Future
from the result of
the computation.
Support for Await.result
.
Choose the first Future to be satisfied.
Choose the first Future to be satisfied.
another Future
a new Future whose result is that of the first of this and other to return
Convert a Twitter Future to a Java native Future.
Convert a Twitter Future to a Java native Future. This should match the semantics of a Java Future as closely as possible to avoid issues with the way another API might use them. See:
http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html#cancel(boolean)
An Offer for this future.
When this future completes, run f
on that completed result
whether or not this computation was successful.
When this future completes, run f
on that completed result
whether or not this computation was successful.
The returned Future
will be satisfied when this,
the original future, and f
are done.
Transform the Future[A]
into a Future[B]
using the
FutureTransformer.
Transform the Future[A]
into a Future[B]
using the
FutureTransformer. The FutureTransformer handles both success
(Return) and failure (Throw) values by implementing map
/flatMap
and handle
/rescue
. This method is typically used by Java
programs because it avoids the use of small Function objects.
The FutureTransformer must implement either flatMap
or map
and may optionally implement handle
. Failing to
implement a method will result in a run-time error (AbstractMethodError
).
addEventListener for a Java friendly way to perform side-effects.
transform for a Scala API.
Convert this Future[A]
to a Future[Unit]
by discarding the result.
Convert this Future[A]
to a Future[Unit]
by discarding the result.
failed futures will remain as is.
Convert this Future[A]
to a Future[Void]
by discarding the result.
Convert this Future[A]
to a Future[Void]
by discarding the result.
failed futures will remain as is.
Returns a Future[Boolean]
indicating whether two Futures are equivalent.
Returns a Future[Boolean]
indicating whether two Futures are equivalent.
Note that
Future.exception(e).willEqual(Future.exception(e)) == Future.value(true)
.
Future.exception(e).willEqual(Future.exception(e)) == Future.value(true) }}}
Returns a new Future that fails if it is not satisfied in time.
Returns a new Future that fails if it is not satisfied in time.
Note: On timeout, the underlying future is not interrupted.
to run timeout on.
indicates how long you are willing to wait for the result to be available.
exception to throw.
Returns a new Future that fails if it is not satisfied in time.
Returns a new Future that fails if it is not satisfied in time.
Note: On timeout, the underlying future is not interrupted.
Returns a new Future that fails if it is not satisfied in time.
Returns a new Future that fails if it is not satisfied in time.
Same as the other within
, but with an implicit timer. Sometimes this is more convenient.
Note: On timeout, the underlying future is not interrupted.
A Future which can never be satisfied and is thus always in the pending state.
Future.never for an instance of it.