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.83 by dl, Thu Apr 4 18:52:03 2013 UTC vs.
Revision 1.84 by dl, Fri Apr 5 14:21:16 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines