The underlying Executor is used to execute asynchronous handlers, e.g. via
onComplete(...).
A Future has two states: pending and completed.
| Modifier and Type | Field and Description |
|---|---|
| public static final Executor | DEFAULT_EXECUTOR
The default executor is |
| public static final ExecutorService | DEFAULT_EXECUTOR_SERVICE
Deprecated
Will be removed in Vavr 1.0. Use The default executor service is instead.
ForkJoinPool#commonPool().
|
| Modifier and Type | Method and Description |
|---|---|
| public default Future | |
| public Future | Returns: thisFuture instanceBlocks the current Thread until this Future completed or returns immediately if this Future is already completed. |
| public Future | |
| public default boolean | Returns: false, if this Future is already completed or could not be cancelled, otherwise true.Cancels the Future. |
| public boolean | Returns: false, if this Future is already completed or could not be cancelled, otherwise true.true if a running thread should be interrupted, otherwise a running thread
is allowed to complete its computation.Cancels the Future. |
| public default < The new value type R> Future | Returns: A newFuture instance containing value of type RA function that is not necessarily defined on value of this future. partialFunction)Collects value that is in the domain of the given |
| public default Executor | |
| public ExecutorService | Returns: (never)
Deprecated
Removed starting with Vavr 0.10.0, use
executor() instead.
This method is deprecated. |
| public static < The value type of a successful result. T> Future | Returns: A failedFuture.The reason why it failed. exception)Creates a failed |
| public static < The value type of a successful result. T> Future | |
| public default Future | Returns: A new Future which contains an exception at a point of time.A projection that inverses the result of this Future. |
| public default Future | Returns: A new FutureA fallback future computation that)Returns a Future that returns the result of this Future, if it is a success. |
| public default Future | |
| public default Future | Returns: A newFutureA checked predicate predicate)Filters the result of this |
| public static < Result type of the futures. T> Future | Returns: A Future of anOption of the first result of the given futures that satisfies the given predicate.An iterable of futures. futures, Predicate<? super T> A predicate that tests successful future results. predicate)Returns a |
| public static < Result type of the futures. T> Future | Returns: A Future of anOption of the first result of the given futures that satisfies the given predicate.An executor, Iterable<? extends Future<? extends T>> Executor.An iterable of futures. futures, Predicate<? super T> A predicate that tests successful future results. predicate)Returns a |
| public static < The result type. T> Future | Returns: A newFuture.An iterable of futures. futures)Returns a new |
| public static < The result type. T> Future | |
| public default <U> Future | |
| public default <U> Future | |
| public static < The result type of the given T, Futures.The fold result type. U> Future | Returns: A newFuture that will contain the fold result.An iterable of futures. futures, U The zero element of the fold. zero, BiFunction<? super U, ? super T, ? extends U> The fold operation. f)Returns a Future which contains the result of the fold of the given future values. |
| public static < The result type of the given T, Futures.The fold result type. U> Future | Returns: A newFuture that will contain the fold result.An executor, Iterable<? extends Future<? extends T>> Executor.An iterable of futures. futures, U The zero element of the fold. zero, BiFunction<? super U, ? super T, ? extends U> The fold operation. f)Returns a Future which contains the result of the fold of the given future values. |
| public default void | forEach(Consumer<? super T>
A action)ConsumerOverrides default io. Performs the given |
| public static < Result type of the Future T> Future | fromCompletableFuture(CompletableFuture<T> future)
Creates a |
| public static < Result type of the Future T> Future | fromCompletableFuture(Executor
An executor, CompletableFuture<T> future)Executor.Creates a |
| public static < Result type of the Future T> Future | Returns: A newFuture wrapping the result of the Java futureCreates a |
| public static < Result type of the Future T> Future | Returns: A newFuture wrapping the result of the Java futureAn executor, Future<T> future)Executor.Creates a |
| public static < The value type of a successful result. T> Future | Returns: A completedFuture which contains either a Success or a Failure.The result. result)Creates a |
| public static < The value type of a successful result. T> Future | |
| public default T | Returns: The value of thisFuture.Implements io. Gets the value if the computation result is a |
| public default Option | Returns: None if the Future is not completed yet. Returns Some(Throwable) if the Future was completed with a failure.Returns the underlying exception of this Future, syntactic sugar for |
| public Option | Returns: None, if the Future is not yet completed or was cancelled, otherwise Some(Try).Returns the value of the Future. |
| public default boolean | Returns: trueImplements io. A |
| public boolean | Returns: true, if the computation was cancelled, false otherwiseChecks if this Future is cancelled, i.e. the thread was forced to stop before completion. |
| public boolean | Returns: true, if the computation successfully finished, failed or was cancelled, false otherwise.Checks if this Future is completed, i.e. has a value. |
| public default boolean | Returns: true, if this future succeeded with a value, false otherwise.Implements io. Checks, if this future has a value. |
| public default boolean | Returns: true, if this Future completed and is a Failure, false otherwise.Checks if this Future completed with a failure. |
| public default boolean | |
| public default boolean | |
| public default boolean | Returns: true, if this Future completed and is a Success, false otherwise.Checks if this Future completed with a success. |
| public default Iterator | |
| public default <U> Future | map(Function<? super T, ? extends U>
A mapper mapper)Implements io. Maps the underlying value to a different component type. |
| public default <U> Future | |
| public static < Component type of the T> FutureFuture. | |
| public static < Type of the computation result. T> Future | Returns: A new Future instance.A computation. computation)Starts an asynchronous computation, backed by the |
| public static < Type of the computation result. T> Future | Returns: A new Future instance.An executor, CheckedFunction0<? extends T> Executor.A computation. computation)Starts an asynchronous computation, backed by the given |
| public static < Type of the computation result. T> Future | Returns: A new Future instanceA computation computation)
Deprecated
Will be removed. Use
Future.of(callable::call) instead of Future.ofCallable(callable).
Starts an asynchronous computation, backed by the |
| public static < Type of the computation result. T> Future | Returns: A new Future instanceAn executor service. executor, Callable<? extends T> A computation. computation)
Deprecated
Will be removed. Use
Future.of(executor, callable::call) instead of Future.ofCallable(executor, callable).
Starts an asynchronous computation, backed by the given |
| public static < Type of the computation result. T> Future | Returns: A new Future instanceA computation. computation)
Deprecated
Will be removed. Use
Future.of(supplier::get) instead of Future.ofSupplier(supplier).
Starts an asynchronous computation, backed by the |
| public static < Type of the computation result. T> Future | Returns: A new Future instanceAn executor service. executor, Supplier<? extends T> A computation. computation)
Deprecated
Will be removed. Use
Future.of(executor, supplier::get) instead of Future.ofSupplier(executor, supplier).
Starts an asynchronous computation, backed by the given |
| public Future | Returns: this FutureAn action to be performed when this future is complete. action)Performs the action once the Future is complete. |
| public default Future | Returns: this FutureAn action to be performed when this future failed. action)Performs the action once the Future is complete and the result is a |
| public default Future | Returns: this FutureAn action to be performed when this future succeeded. action)Performs the action once the Future is complete and the result is a |
| public default Future | |
| public default Future | |
| public default Future | peek(Consumer<? super T>
The action that will be performed on the element(s). action)Implements io. Performs the given |
| public default Future | |
| public default Future | Returns: A new Future.A function which takes the exception of a failure and returns a new future. f)Handles a failure of this Future by returning the result of another Future. |
| public static < The result type of the given T> FutureFutures. | Returns: A newFuture that will contain the reduce result.An iterable of futures. futures, BiFunction<? super T, ? super T, ? extends T> The reduce operation. f)Returns a Future which contains the reduce result of the given future values. |
| public static < The result type of the given T> FutureFutures. | Returns: A newFuture that will contain the reduce result.An executor, Iterable<? extends Future<? extends T>> Executor.An iterable of futures. futures, BiFunction<? super T, ? super T, ? extends T> The reduce operation. f)Returns a Future which contains the reduce result of the given future values. |
| public static < Type of the result T> Future | |
| public static < Type of the result T> Future | Returns: a newFuture instanceAn executor, Task<? extends T> Executor that runs the given computationA computational task task)
Deprecated
Experimental API
Creates a (possibly blocking) Future that runs the results of the given
|
| public static Future | Returns: A new Future instance which results in nothing.A unit of work. unit)Runs an asynchronous computation, backed by the |
| public static Future | Returns: A new Future instance which results in nothing.An executor, CheckedRunnable Executor.A unit of work. unit)Starts an asynchronous computation, backed by the given |
| public static Future | Returns: A new Future instanceA computation computation)
Deprecated
Will be removed. Use
Future.of(runnable::run) instead of Future.runRunnable(runnable).
Starts an asynchronous computation, backed by the |
| public static Future | Returns: A new Future instanceAn executor service. executor, Runnable A computation. computation)
Deprecated
Will be removed. Use
Future.of(executor, runnable::run) instead of Future.runRunnable(executor, runnable).
Starts an asynchronous computation, backed by the given |
| public static < Result type of the futures. T> Future | |
| public static < Result type of the futures. T> Future | |
| public default String | stringPrefix()
Implements io. Returns the name of this Value type, which is used by toString(). |
| public static < The value type of a successful result. T> Future | Returns: A succeededFuture.The result. result)Creates a succeeded |
| public static < The value type of a successful result. T> Future | Returns: A succeededFuture.An executor, T Executor.The result. result)Creates a succeeded |
| public default CompletableFuture | toCompletableFuture()
Overrides default io. Converts this to a |
| public default < Type of transformation result U> U | |
| public default < Generic type of transformation U> FutureTry result | Returns: AFuture of type UA transformation f)Transforms the value of this |
| public static < The type of the given values. T, The mapped value type. U> Future | |
| public static < The type of the given values. T, The mapped value type. U> Future | traverse(Executor
An executor, Iterable<? extends T> Executor.An values, Function<? super T, ? extends Future<? extends U>> Iterable of values.A mapper of values to Futures mapper)Maps the values of an iterable in parallel to a sequence of mapped values into a single |
| public default < Result type of U> Futurethat | |
| public default < Result type of U, thatResult type of R> Futuref | Returns: A new Future that returns both Future results.Another Future that, BiFunction<? super T, ? super U, ? extends R> The combinator function combinator)Returns a this and that Future result combined using a given combinator function. |