提交 b51cc74c 编写于 作者: D dl

8056249: Improve CompletableFuture resource usage

Reviewed-by: psandoz, chegar, martin
上级 4352a351
...@@ -407,7 +407,7 @@ public interface CompletionStage<T> { ...@@ -407,7 +407,7 @@ public interface CompletionStage<T> {
/** /**
* Returns a new CompletionStage that, when this and the other * Returns a new CompletionStage that, when this and the other
* given stage complete normally, executes the given action using * given stage complete normally, executes the given action using
* the supplied executor * the supplied executor.
* *
* See the {@link CompletionStage} documentation for rules * See the {@link CompletionStage} documentation for rules
* covering exceptional completion. * covering exceptional completion.
...@@ -569,7 +569,7 @@ public interface CompletionStage<T> { ...@@ -569,7 +569,7 @@ public interface CompletionStage<T> {
/** /**
* Returns a new CompletionStage that, when either this or the * Returns a new CompletionStage that, when either this or the
* other given stage complete normally, executes the given action * other given stage complete normally, executes the given action
* using supplied executor. * using the supplied executor.
* *
* See the {@link CompletionStage} documentation for rules * See the {@link CompletionStage} documentation for rules
* covering exceptional completion. * covering exceptional completion.
...@@ -649,10 +649,15 @@ public interface CompletionStage<T> { ...@@ -649,10 +649,15 @@ public interface CompletionStage<T> {
(Function<Throwable, ? extends T> fn); (Function<Throwable, ? extends T> fn);
/** /**
* Returns a new CompletionStage with the same result or exception * Returns a new CompletionStage with the same result or exception as
* as this stage, and when this stage completes, executes the * this stage, that executes the given action when this stage completes.
* given action with the result (or {@code null} if none) and the *
* exception (or {@code null} if none) of this stage. * <p>When this stage is complete, the given action is invoked with the
* result (or {@code null} if none) and the exception (or {@code null}
* if none) of this stage as arguments. The returned stage is completed
* when the action returns. If the supplied action itself encounters an
* exception, then the returned stage exceptionally completes with this
* exception unless this stage also completed exceptionally.
* *
* @param action the action to perform * @param action the action to perform
* @return the new CompletionStage * @return the new CompletionStage
...@@ -661,12 +666,16 @@ public interface CompletionStage<T> { ...@@ -661,12 +666,16 @@ public interface CompletionStage<T> {
(BiConsumer<? super T, ? super Throwable> action); (BiConsumer<? super T, ? super Throwable> action);
/** /**
* Returns a new CompletionStage with the same result or exception * Returns a new CompletionStage with the same result or exception as
* as this stage, and when this stage completes, executes the * this stage, that executes the given action using this stage's
* given action executes the given action using this stage's * default asynchronous execution facility when this stage completes.
* default asynchronous execution facility, with the result (or *
* {@code null} if none) and the exception (or {@code null} if * <p>When this stage is complete, the given action is invoked with the
* none) of this stage as arguments. * result (or {@code null} if none) and the exception (or {@code null}
* if none) of this stage as arguments. The returned stage is completed
* when the action returns. If the supplied action itself encounters an
* exception, then the returned stage exceptionally completes with this
* exception unless this stage also completed exceptionally.
* *
* @param action the action to perform * @param action the action to perform
* @return the new CompletionStage * @return the new CompletionStage
...@@ -675,11 +684,16 @@ public interface CompletionStage<T> { ...@@ -675,11 +684,16 @@ public interface CompletionStage<T> {
(BiConsumer<? super T, ? super Throwable> action); (BiConsumer<? super T, ? super Throwable> action);
/** /**
* Returns a new CompletionStage with the same result or exception * Returns a new CompletionStage with the same result or exception as
* as this stage, and when this stage completes, executes using * this stage, that executes the given action using the supplied
* the supplied Executor, the given action with the result (or * Executor when this stage completes.
* {@code null} if none) and the exception (or {@code null} if *
* none) of this stage as arguments. * <p>When this stage is complete, the given action is invoked with the
* result (or {@code null} if none) and the exception (or {@code null}
* if none) of this stage as arguments. The returned stage is completed
* when the action returns. If the supplied action itself encounters an
* exception, then the returned stage exceptionally completes with this
* exception unless this stage also completed exceptionally.
* *
* @param action the action to perform * @param action the action to perform
* @param executor the executor to use for asynchronous execution * @param executor the executor to use for asynchronous execution
...@@ -693,9 +707,11 @@ public interface CompletionStage<T> { ...@@ -693,9 +707,11 @@ public interface CompletionStage<T> {
* Returns a new CompletionStage that, when this stage completes * Returns a new CompletionStage that, when this stage completes
* either normally or exceptionally, is executed with this stage's * either normally or exceptionally, is executed with this stage's
* result and exception as arguments to the supplied function. * result and exception as arguments to the supplied function.
* The given function is invoked with the result (or {@code null} *
* if none) and the exception (or {@code null} if none) of this * <p>When this stage is complete, the given function is invoked
* stage when complete as arguments. * with the result (or {@code null} if none) and the exception (or
* {@code null} if none) of this stage as arguments, and the
* function's result is used to complete the returned stage.
* *
* @param fn the function to use to compute the value of the * @param fn the function to use to compute the value of the
* returned CompletionStage * returned CompletionStage
...@@ -710,9 +726,11 @@ public interface CompletionStage<T> { ...@@ -710,9 +726,11 @@ public interface CompletionStage<T> {
* either normally or exceptionally, is executed using this stage's * either normally or exceptionally, is executed using this stage's
* default asynchronous execution facility, with this stage's * default asynchronous execution facility, with this stage's
* result and exception as arguments to the supplied function. * result and exception as arguments to the supplied function.
* The given function is invoked with the result (or {@code null} *
* if none) and the exception (or {@code null} if none) of this * <p>When this stage is complete, the given function is invoked
* stage when complete as arguments. * with the result (or {@code null} if none) and the exception (or
* {@code null} if none) of this stage as arguments, and the
* function's result is used to complete the returned stage.
* *
* @param fn the function to use to compute the value of the * @param fn the function to use to compute the value of the
* returned CompletionStage * returned CompletionStage
...@@ -726,10 +744,12 @@ public interface CompletionStage<T> { ...@@ -726,10 +744,12 @@ public interface CompletionStage<T> {
* Returns a new CompletionStage that, when this stage completes * Returns a new CompletionStage that, when this stage completes
* either normally or exceptionally, is executed using the * either normally or exceptionally, is executed using the
* supplied executor, with this stage's result and exception as * supplied executor, with this stage's result and exception as
* arguments to the supplied function. The given function is * arguments to the supplied function.
* invoked with the result (or {@code null} if none) and the *
* exception (or {@code null} if none) of this stage when complete * <p>When this stage is complete, the given function is invoked
* as arguments. * with the result (or {@code null} if none) and the exception (or
* {@code null} if none) of this stage as arguments, and the
* function's result is used to complete the returned stage.
* *
* @param fn the function to use to compute the value of the * @param fn the function to use to compute the value of the
* returned CompletionStage * returned CompletionStage
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册