ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CompletableFuture.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CompletableFuture.java (file contents):
Revision 1.209 by jsr166, Sat Sep 10 04:06:51 2016 UTC vs.
Revision 1.210 by jsr166, Wed Sep 21 06:03:17 2016 UTC

# Line 2530 | Line 2530 | public class CompletableFuture<T> implem
2530       * exceptionally with a CompletionException with this exception as
2531       * cause.
2532       *
2533 +     * <p>Unless overridden by a subclass, a new non-minimal
2534 +     * CompletableFuture with all methods available can be obtained from
2535 +     * a minimal CompletionStage via {@link #toCompletableFuture()}.
2536 +     * For example, completion of a minimal stage can be awaited by
2537 +     *
2538 +     * <pre> {@code minimalStage.toCompletableFuture().join(); }</pre>
2539 +     *
2540       * @return the new CompletionStage
2541       * @since 9
2542       */
# Line 2824 | Line 2831 | public class CompletableFuture<T> implem
2831          @Override public CompletableFuture<T> completeOnTimeout
2832              (T value, long timeout, TimeUnit unit) {
2833              throw new UnsupportedOperationException(); }
2834 +        @Override public CompletableFuture<T> toCompletableFuture() {
2835 +            Object r;
2836 +            if ((r = result) != null)
2837 +                return new CompletableFuture<T>(encodeRelay(r));
2838 +            else {
2839 +                CompletableFuture<T> d = new CompletableFuture<>();
2840 +                unipush(new UniRelay<T,T>(d, this));
2841 +                return d;
2842 +            }
2843 +        }
2844      }
2845  
2846      // VarHandle mechanics

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines