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

Comparing jsr166/src/jdk8/java/util/concurrent/CompletableFuture.java (file contents):
Revision 1.7 by jsr166, Sat Sep 17 22:19:59 2016 UTC vs.
Revision 1.8 by jsr166, Sat Oct 8 17:32:35 2016 UTC

# Line 2545 | Line 2545 | public class CompletableFuture<T> implem
2545       * exceptionally with a CompletionException with this exception as
2546       * cause.
2547       *
2548 +     * <p>Unless overridden by a subclass, a new non-minimal
2549 +     * CompletableFuture with all methods available can be obtained from
2550 +     * a minimal CompletionStage via {@link #toCompletableFuture()}.
2551 +     * For example, completion of a minimal stage can be awaited by
2552 +     *
2553 +     * <pre> {@code minimalStage.toCompletableFuture().join(); }</pre>
2554 +     *
2555       * @return the new CompletionStage
2556       * @since 9
2557       */
# Line 2839 | Line 2846 | public class CompletableFuture<T> implem
2846          @Override public CompletableFuture<T> completeOnTimeout
2847              (T value, long timeout, TimeUnit unit) {
2848              throw new UnsupportedOperationException(); }
2849 +        @Override public CompletableFuture<T> toCompletableFuture() {
2850 +            Object r;
2851 +            if ((r = result) != null)
2852 +                return new CompletableFuture<T>(encodeRelay(r));
2853 +            else {
2854 +                CompletableFuture<T> d = new CompletableFuture<>();
2855 +                unipush(new UniRelay<T,T>(d, this));
2856 +                return d;
2857 +            }
2858 +        }
2859      }
2860  
2861      // Unsafe mechanics

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines