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.124 by jsr166, Sat May 31 00:37:54 2014 UTC vs.
Revision 1.125 by jsr166, Sat May 31 05:52:50 2014 UTC

# Line 473 | Line 473 | public class CompletableFuture<T> implem
473      final <S> boolean uniApply(CompletableFuture<S> a,
474                                 Function<? super S,? extends T> f,
475                                 UniApply<S,T> c) {
476 <        Object r; T u; Throwable x;
476 >        Object r; T t; Throwable x;
477          if (a == null || (r = a.result) == null || f == null)
478              return false;
479          if (result == null) {
# Line 485 | Line 485 | public class CompletableFuture<T> implem
485                  else
486                      x = null;
487                  if (x != null)
488 <                    u = null;
488 >                    t = null;
489                  else if (c != null && !c.claim())
490                      return false;
491                  else {
492 <                    @SuppressWarnings("unchecked") S t = (S) r;
493 <                    u = f.apply(t);
492 >                    @SuppressWarnings("unchecked") S s = (S) r;
493 >                    t = f.apply(s);
494                  }
495              } catch (Throwable ex) {
496                  x = ex;
497 <                u = null;
497 >                t = null;
498              }
499 <            internalComplete(encodeOutcome(u, x));
499 >            internalComplete(encodeOutcome(t, x));
500          }
501          return true;
502      }
# Line 547 | Line 547 | public class CompletableFuture<T> implem
547                      if (c != null && !c.claim())
548                          return false;
549                      else {
550 <                        @SuppressWarnings("unchecked") S t = (S) r;
551 <                        f.accept(t);
550 >                        @SuppressWarnings("unchecked") S s = (S) r;
551 >                        f.accept(s);
552                      }
553                  }
554              } catch (Throwable ex) {
# Line 701 | Line 701 | public class CompletableFuture<T> implem
701      final <S> boolean uniHandle(CompletableFuture<S> a,
702                                  BiFunction<? super S, Throwable, ? extends T> f,
703                                  UniHandle<S,T> c) {
704 <        Object r; T u; Throwable x, y;
704 >        Object r; T t; Throwable x, y;
705          if (a == null || (r = a.result) == null || f == null)
706              return false;
707          if (result == null) {
# Line 715 | Line 715 | public class CompletableFuture<T> implem
715                  if (c != null && !c.claim())
716                      return false;
717                  else {
718 <                    @SuppressWarnings("unchecked") S t = (S) r;
719 <                    u = f.apply(t, x);
718 >                    @SuppressWarnings("unchecked") S s = (S) r;
719 >                    t = f.apply(s, x);
720                      y = null;
721                  }
722              } catch (Throwable ex) {
723                  y = ex;
724 <                u = null;
724 >                t = null;
725              }
726 <            internalComplete(encodeOutcome(u, y));
726 >            internalComplete(encodeOutcome(t, y));
727          }
728          return true;
729      }
# Line 861 | Line 861 | public class CompletableFuture<T> implem
861                      if (c != null && !c.claim())
862                          return false;
863                      else {
864 <                        @SuppressWarnings("unchecked") S t = (S) r;
864 >                        @SuppressWarnings("unchecked") S s = (S) r;
865                          CompletableFuture<T> g =
866 <                            f.apply(t).toCompletableFuture();
866 >                            f.apply(s).toCompletableFuture();
867                          if (g.result == null || !uniRelay(g)) {
868                              UniRelay<T> copy = new UniRelay<T>(this, g);
869                              g.push(copy);
# Line 995 | Line 995 | public class CompletableFuture<T> implem
995                                  CompletableFuture<S> b,
996                                  BiFunction<? super R,? super S,? extends T> f,
997                                  BiApply<R,S,T> c) {
998 <        Object r, s; T v; Throwable x;
998 >        Object r, s; T t; Throwable x;
999          if (a == null || (r = a.result) == null ||
1000              b == null || (s = b.result) == null || f == null)
1001              return false;
# Line 1012 | Line 1012 | public class CompletableFuture<T> implem
1012                      s = null;
1013                  }
1014                  if (x != null)
1015 <                    v = null;
1015 >                    t = null;
1016                  else if (c != null && !c.claim())
1017                      return false;
1018                  else {
1019 <                    @SuppressWarnings("unchecked") R t = (R) r;
1020 <                    @SuppressWarnings("unchecked") S u = (S) s;
1021 <                    v = f.apply(t, u);
1019 >                    @SuppressWarnings("unchecked") R rr = (R) r;
1020 >                    @SuppressWarnings("unchecked") S ss = (S) s;
1021 >                    t = f.apply(rr, ss);
1022                  }
1023              } catch (Throwable ex) {
1024                  x = ex;
1025 <                v = null;
1025 >                t = null;
1026              }
1027 <            internalComplete(encodeOutcome(v, x));
1027 >            internalComplete(encodeOutcome(t, x));
1028          }
1029          return true;
1030      }
# Line 1088 | Line 1088 | public class CompletableFuture<T> implem
1088                      if (c != null && !c.claim())
1089                          return false;
1090                      else {
1091 <                        @SuppressWarnings("unchecked") R t = (R) r;
1092 <                        @SuppressWarnings("unchecked") S u = (S) s;
1093 <                        f.accept(t, u);
1091 >                        @SuppressWarnings("unchecked") R rr = (R) r;
1092 >                        @SuppressWarnings("unchecked") S ss = (S) s;
1093 >                        f.accept(rr, ss);
1094                      }
1095                  }
1096              } catch (Throwable ex) {
# Line 1282 | Line 1282 | public class CompletableFuture<T> implem
1282                                            CompletableFuture<S> b,
1283                                            Function<? super R, ? extends T> f,
1284                                            OrApply<R,S,T> c) {
1285 <        Object r; T u; Throwable x;
1285 >        Object r; T t; Throwable x;
1286          if (a == null || b == null ||
1287              ((r = a.result) == null && (r = b.result) == null) || f == null)
1288              return false;
# Line 1295 | Line 1295 | public class CompletableFuture<T> implem
1295                  else
1296                      x = null;
1297                  if (x != null)
1298 <                    u = null;
1298 >                    t = null;
1299                  else if (c != null && !c.claim())
1300                      return false;
1301                  else {
1302 <                    @SuppressWarnings("unchecked") R t = (R) r;
1303 <                    u = f.apply(t);
1302 >                    @SuppressWarnings("unchecked") R rr = (R) r;
1303 >                    t = f.apply(rr);
1304                  }
1305              } catch (Throwable ex) {
1306                  x = ex;
1307 <                u = null;
1307 >                t = null;
1308              }
1309 <            internalComplete(encodeOutcome(u, x));
1309 >            internalComplete(encodeOutcome(t, x));
1310          }
1311          return true;
1312      }
# Line 1367 | Line 1367 | public class CompletableFuture<T> implem
1367                      if (c != null && !c.claim())
1368                          return false;
1369                      else {
1370 <                        @SuppressWarnings("unchecked") R t = (R) r;
1371 <                        f.accept(t);
1370 >                        @SuppressWarnings("unchecked") R rr = (R) r;
1371 >                        f.accept(rr);
1372                      }
1373                  }
1374              } catch (Throwable ex) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines