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.104 by dl, Fri May 2 16:34:00 2014 UTC vs.
Revision 1.105 by jsr166, Fri May 2 23:26:56 2014 UTC

# Line 287 | Line 287 | public class CompletableFuture<T> implem
287          CompletableFuture<T> dep; // the CompletableFuture to trigger
288          Async(CompletableFuture<T> dep) { this.dep = dep; }
289  
290 <        abstract void compute(); // call the associated "now" method
290 >        abstract void compute(); // call the associated "now" method
291  
292 <        public final boolean exec() {
292 >        public final boolean exec() {
293              CompletableFuture<T> d;
294              if ((d = dep) != null) {
295                  if (d.result == null) // suppress if cancelled
# Line 428 | Line 428 | public class CompletableFuture<T> implem
428      }
429  
430      static final class AsyncApply<T,U> extends Async<U> {
431 <        T arg;  Function<? super T,? extends U> fn;
431 >        T arg;  Function<? super T,? extends U> fn;
432          AsyncApply(CompletableFuture<U> dep, T arg,
433                     Function<? super T,? extends U> fn) {
434              super(dep); this.arg = arg; this.fn = fn;
435          }
436 <        final void compute() { nowApply(null, dep, arg, fn); }
436 >        final void compute() { nowApply(null, dep, arg, fn); }
437          private static final long serialVersionUID = 5232453952276885070L;
438      }
439  
# Line 498 | Line 498 | public class CompletableFuture<T> implem
498      }
499  
500      static final class AsyncAccept<T,U> extends Async<U> {
501 <        T arg; Consumer<? super T> fn;
501 >        T arg; Consumer<? super T> fn;
502          AsyncAccept(CompletableFuture<U> dep, T arg,
503                      Consumer<? super T> fn) {
504              super(dep); this.arg = arg; this.fn = fn;
505          }
506 <        final void compute() { nowAccept(null, dep, arg, fn); }
506 >        final void compute() { nowAccept(null, dep, arg, fn); }
507          private static final long serialVersionUID = 5232453952276885070L;
508      }
509  
# Line 559 | Line 559 | public class CompletableFuture<T> implem
559      }
560  
561      static final class AsyncRun<T> extends Async<T> {
562 <        Runnable fn;
562 >        Runnable fn;
563          AsyncRun(CompletableFuture<T> dep, Runnable fn) {
564              super(dep); this.fn = fn;
565          }
566 <        final void compute() { nowRun(null, dep, null, fn); }
566 >        final void compute() { nowRun(null, dep, null, fn); }
567          private static final long serialVersionUID = 5232453952276885070L;
568      }
569  
570      static final class DelayedRun extends UniCompletion<Void> {
571 <        Runnable fn;
571 >        Runnable fn;
572          DelayedRun(Executor async, CompletableFuture<Void> dep,
573                     CompletableFuture<?> src, Runnable fn) {
574              super(async, dep, src); this.fn = fn;
# Line 613 | Line 613 | public class CompletableFuture<T> implem
613      }
614  
615      static final class AsyncSupply<T> extends Async<T> {
616 <        Supplier<T> fn;
616 >        Supplier<T> fn;
617          AsyncSupply(CompletableFuture<T> dep, Supplier<T> fn) {
618              super(dep); this.fn = fn;
619          }
620 <        final void compute() { nowSupply(dep, fn); }
620 >        final void compute() { nowSupply(dep, fn); }
621          private static final long serialVersionUID = 5232453952276885070L;
622      }
623  
# Line 650 | Line 650 | public class CompletableFuture<T> implem
650      }
651  
652      static final class AsyncWhen<T> extends Async<T> {
653 <        Object arg; BiConsumer<? super T,? super Throwable> fn;
653 >        Object arg; BiConsumer<? super T,? super Throwable> fn;
654          AsyncWhen(CompletableFuture<T> dep, Object arg,
655                    BiConsumer<? super T,? super Throwable> fn) {
656              super(dep); this.arg = arg; this.fn = fn;
657          }
658 <        final void compute() { nowWhen(null, dep, arg, fn); }
658 >        final void compute() { nowWhen(null, dep, arg, fn); }
659          private static final long serialVersionUID = 5232453952276885070L;
660      }
661  
# Line 869 | Line 869 | public class CompletableFuture<T> implem
869      }
870  
871      static final class AsyncCompose<T,U> extends Async<U> {
872 <        T arg; Function<? super T, ? extends CompletionStage<U>> fn;
872 >        T arg; Function<? super T, ? extends CompletionStage<U>> fn;
873          AsyncCompose(CompletableFuture<U> dep, T arg,
874                       Function<? super T, ? extends CompletionStage<U>> fn) {
875              super(dep); this.arg = arg; this.fn = fn;
876          }
877 <        final void compute() { nowCompose(null, dep, arg, fn); }
877 >        final void compute() { nowCompose(null, dep, arg, fn); }
878          private static final long serialVersionUID = 5232453952276885070L;
879      }
880  
# Line 1022 | Line 1022 | public class CompletableFuture<T> implem
1022      }
1023  
1024      static final class AsyncCombine<T,U,V> extends Async<V> {
1025 <        T arg1; U arg2; BiFunction<? super T,? super U,? extends V> fn;
1025 >        T arg1; U arg2; BiFunction<? super T,? super U,? extends V> fn;
1026          AsyncCombine(CompletableFuture<V> dep, T arg1, U arg2,
1027                       BiFunction<? super T,? super U,? extends V> fn) {
1028              super(dep); this.arg1 = arg1; this.arg2 = arg2; this.fn = fn;
1029          }
1030 <        final void compute() { nowCombine(null, dep, arg1, arg2, fn); }
1030 >        final void compute() { nowCombine(null, dep, arg1, arg2, fn); }
1031          private static final long serialVersionUID = 5232453952276885070L;
1032      }
1033  
# Line 1104 | Line 1104 | public class CompletableFuture<T> implem
1104      }
1105  
1106      static final class AsyncAcceptBoth<T,U,V> extends Async<V> {
1107 <        T arg1; U arg2; BiConsumer<? super T,? super U> fn;
1107 >        T arg1; U arg2; BiConsumer<? super T,? super U> fn;
1108          AsyncAcceptBoth(CompletableFuture<V> dep, T arg1, U arg2,
1109                          BiConsumer<? super T,? super U> fn) {
1110              super(dep); this.arg1 = arg1; this.arg2 = arg2; this.fn = fn;
1111          }
1112 <        final void compute() { nowAcceptBoth(null, dep, arg1, arg2, fn); }
1112 >        final void compute() { nowAcceptBoth(null, dep, arg1, arg2, fn); }
1113          private static final long serialVersionUID = 5232453952276885070L;
1114      }
1115  
# Line 1654 | Line 1654 | public class CompletableFuture<T> implem
1654       * while waiting
1655       */
1656      public T get() throws InterruptedException, ExecutionException {
1657 <        Object r;
1657 >        Object r;
1658          return reportGet((r = result) == null ?  waitingGet(true) : r);
1659      }
1660  
# Line 1673 | Line 1673 | public class CompletableFuture<T> implem
1673       */
1674      public T get(long timeout, TimeUnit unit)
1675          throws InterruptedException, ExecutionException, TimeoutException {
1676 <        Object r;
1676 >        Object r;
1677          long nanos = unit.toNanos(timeout);
1678          return reportGet((r = result) == null ?  timedGet(nanos) : r);
1679      }
# Line 1694 | Line 1694 | public class CompletableFuture<T> implem
1694       */
1695      public T join() {
1696          Object r;
1697 <        return reportJoin((r = result) == null ? waitingGet(false) : r);
1697 >        return reportJoin((r = result) == null ? waitingGet(false) : r);
1698      }
1699  
1700      /**
# Line 1709 | Line 1709 | public class CompletableFuture<T> implem
1709       */
1710      public T getNow(T valueIfAbsent) {
1711          Object r;
1712 <        return (r = result) == null? valueIfAbsent : reportJoin(r);
1712 >        return (r = result) == null? valueIfAbsent : reportJoin(r);
1713      }
1714  
1715      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines