Method Detail

timeout

Creates a CompletionStage that returns either the input stage, or a timeout.
Note that timeout is not the same as cancellation. Even in case of timeout,
the given completion stage will still complete, even though that completed value
is not returned.

delayed

Create a CompletionStage which, after a delay, will be redeemed with the result of a
given supplier. The completion stage will be called after the delay.
For example, to render a number indicating the delay, you can use the following method:

Create a CompletionStage that is redeemed after a timeout. This method
is useful for returning fallback values on futures.
The underlying implementation uses TimerTask, which has a
resolution in milliseconds.

Type Parameters:

A - the type of the completion's result.

Parameters:

value - The result value to use to complete the CompletionStage.

amount - The amount (expressed with the corresponding unit).

unit - The time unit, i.e. java.util.concurrent.TimeUnit.MILLISECONDS

Returns:

the CompletionStage wrapping the result value

timeout

Creates a CompletionStage timer that throws a PromiseTimeoutException after
a given timeout.
The returned CompletionStage is usually combined with other CompletionStage,
i.e. completionStage.applyToEither(Futures.timeout(delay, unit), Function.identity())
The underlying implementation uses TimerTask, which has a
resolution in milliseconds.
A previous implementation used CompletionStage<Void> which made
it unsuitable for composition. Cast with Futures.<Void>timeout if
necessary.