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.84 by dl, Fri Apr 5 14:21:16 2013 UTC vs.
Revision 1.85 by dl, Fri Apr 5 23:04:42 2013 UTC

# Line 773 | Line 773 | public class CompletableFuture<T> implem
773              this.fn = fn; this.dst = dst;
774              this.executor = executor;
775          }
776
776          public final void run() {
777              final CompletableFuture<? extends T> a;
778              final CompletableFuture<? extends U> b;
779              final BiFunction<? super T,? super U,? extends V> fn;
780              final CompletableFuture<V> dst;
781 <            if ((dst = this.dst) == null ||
782 <                (fn = this.fn) == null ||
783 <                (a = this.src) == null ||
784 <                (b = this.snd) == null)
785 <                return;
786 <            final Object r = a.result, s = b.result;
787 <            final T t; final U u; Throwable ex;
788 <            if (r instanceof AltResult) {
789 <                ex = ((AltResult)r).ex;
790 <                t = null;
791 <            } else {
792 <                ex = null;
793 <                @SuppressWarnings("unchecked") T tr = (T) r;
794 <                t = tr;
795 <            }
796 <            if (ex != null)
797 <                u = null;
798 <            else if (s instanceof AltResult) {
799 <                ex = ((AltResult)s).ex;
800 <                u = null;
801 <            } else {
802 <                ex = null;
803 <                @SuppressWarnings("unchecked") U us = (U) s;
804 <                u = us;
805 <            }
806 <
807 <            if ((ex != null || (r != null && s != null))
809 <                && compareAndSet(0, 1)) {
781 >            Object r, s; T t; U u; Throwable ex;
782 >            if ((dst = this.dst) != null &&
783 >                (fn = this.fn) != null &&
784 >                (a = this.src) != null &&
785 >                (r = a.result) != null &&
786 >                (b = this.snd) != null &&
787 >                (s = b.result) != null &&
788 >                compareAndSet(0, 1)) {
789 >                if (r instanceof AltResult) {
790 >                    ex = ((AltResult)r).ex;
791 >                    t = null;
792 >                }
793 >                else {
794 >                    ex = null;
795 >                    @SuppressWarnings("unchecked") T tr = (T) r;
796 >                    t = tr;
797 >                }
798 >                if (ex != null)
799 >                    u = null;
800 >                else if (s instanceof AltResult) {
801 >                    ex = ((AltResult)s).ex;
802 >                    u = null;
803 >                }
804 >                else {
805 >                    @SuppressWarnings("unchecked") U us = (U) s;
806 >                    u = us;
807 >                }
808                  Executor e = executor;
809                  V v = null;
810                  if (ex == null) {
# Line 846 | Line 844 | public class CompletableFuture<T> implem
844              final CompletableFuture<? extends U> b;
845              final BiConsumer<? super T,? super U> fn;
846              final CompletableFuture<Void> dst;
847 <            if ((dst = this.dst) == null ||
848 <                (fn = this.fn) == null ||
849 <                (a = this.src) == null ||
850 <                (b = this.snd) == null)
851 <                return;
852 <            final Object r = a.result, s = b.result;
853 <            final T t; final U u; Throwable ex;
854 <            if (r instanceof AltResult) {
855 <                ex = ((AltResult)r).ex;
856 <                t = null;
857 <            } else {
858 <                ex = null;
859 <                @SuppressWarnings("unchecked") T tr = (T) r;
860 <                t = tr;
861 <            }
862 <            if (ex != null)
863 <                u = null;
864 <            else if (s instanceof AltResult) {
865 <                ex = ((AltResult)s).ex;
866 <                u = null;
867 <            } else {
868 <                ex = null;
869 <                @SuppressWarnings("unchecked") U us = (U) s;
870 <                u = us;
871 <            }
872 <            if ((ex != null || (r != null && s != null))
873 <                && compareAndSet(0, 1)) {
847 >            Object r, s; T t; U u; Throwable ex;
848 >            if ((dst = this.dst) != null &&
849 >                (fn = this.fn) != null &&
850 >                (a = this.src) != null &&
851 >                (r = a.result) != null &&
852 >                (b = this.snd) != null &&
853 >                (s = b.result) != null &&
854 >                compareAndSet(0, 1)) {
855 >                if (r instanceof AltResult) {
856 >                    ex = ((AltResult)r).ex;
857 >                    t = null;
858 >                }
859 >                else {
860 >                    ex = null;
861 >                    @SuppressWarnings("unchecked") T tr = (T) r;
862 >                    t = tr;
863 >                }
864 >                if (ex != null)
865 >                    u = null;
866 >                else if (s instanceof AltResult) {
867 >                    ex = ((AltResult)s).ex;
868 >                    u = null;
869 >                }
870 >                else {
871 >                    @SuppressWarnings("unchecked") U us = (U) s;
872 >                    u = us;
873 >                }
874                  Executor e = executor;
875                  if (ex == null) {
876                      try {
# Line 911 | Line 909 | public class CompletableFuture<T> implem
909              final CompletableFuture<?> b;
910              final Runnable fn;
911              final CompletableFuture<Void> dst;
912 <            if ((dst = this.dst) == null ||
913 <                (fn = this.fn) == null ||
914 <                (a = this.src) == null ||
915 <                (b = this.snd) == null)
916 <                return;
917 <            final Object r = a.result, s = b.result;
918 <            Throwable ex;
919 <            if (r instanceof AltResult)
920 <                ex = ((AltResult)r).ex;
921 <            else
922 <                ex = null;
923 <            if (ex == null && (s instanceof AltResult))
924 <                ex = ((AltResult)s).ex;
925 <            if ((ex != null || (r != null && s != null))
928 <                && compareAndSet(0, 1)) {
912 >            Object r, s; Throwable ex;
913 >            if ((dst = this.dst) != null &&
914 >                (fn = this.fn) != null &&
915 >                (a = this.src) != null &&
916 >                (r = a.result) != null &&
917 >                (b = this.snd) != null &&
918 >                (s = b.result) != null &&
919 >                compareAndSet(0, 1)) {
920 >                if (r instanceof AltResult)
921 >                    ex = ((AltResult)r).ex;
922 >                else
923 >                    ex = null;
924 >                if (ex == null && (s instanceof AltResult))
925 >                    ex = ((AltResult)s).ex;
926                  Executor e = executor;
927                  if (ex == null) {
928                      try {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines