539 |
|
final boolean isLive() { return dep != null; } |
540 |
|
} |
541 |
|
|
542 |
< |
/** Pushes the given completion (if it exists) unless done. */ |
543 |
< |
final void push(UniCompletion<?,?> c) { |
542 |
> |
/** |
543 |
> |
* Pushes the given completion unless it completes while trying. |
544 |
> |
* Caller should have first checked that result is null. |
545 |
> |
*/ |
546 |
> |
final void unipush(UniCompletion<?,?> c) { |
547 |
|
if (c != null) { |
548 |
< |
while (result == null && !tryPushStack(c)) |
549 |
< |
lazySetNext(c, null); // clear on failure |
548 |
> |
while (!tryPushStack(c)) { |
549 |
> |
if (result != null) { |
550 |
> |
lazySetNext(c, null); |
551 |
> |
break; |
552 |
> |
} |
553 |
> |
} |
554 |
> |
if (result != null) |
555 |
> |
c.tryFire(SYNC); |
556 |
|
} |
557 |
|
} |
558 |
|
|
636 |
|
} |
637 |
|
} |
638 |
|
else { |
639 |
< |
push(c); |
631 |
< |
c.tryFire(SYNC); |
639 |
> |
unipush(c); |
640 |
|
} |
641 |
|
} |
642 |
|
return d; |
699 |
|
} |
700 |
|
} |
701 |
|
else { |
702 |
< |
push(c); |
695 |
< |
c.tryFire(SYNC); |
702 |
> |
unipush(c); |
703 |
|
} |
704 |
|
} |
705 |
|
return d; |
755 |
|
} |
756 |
|
} |
757 |
|
else { |
758 |
< |
push(c); |
752 |
< |
c.tryFire(SYNC); |
758 |
> |
unipush(c); |
759 |
|
} |
760 |
|
} |
761 |
|
return d; |
826 |
|
} |
827 |
|
} |
828 |
|
else { |
829 |
< |
push(c); |
824 |
< |
c.tryFire(SYNC); |
829 |
> |
unipush(c); |
830 |
|
} |
831 |
|
} |
832 |
|
return d; |
890 |
|
} |
891 |
|
} |
892 |
|
else { |
893 |
< |
push(c); |
889 |
< |
c.tryFire(SYNC); |
893 |
> |
unipush(c); |
894 |
|
} |
895 |
|
} |
896 |
|
return d; |
938 |
|
Function<Throwable, ? extends T> f) { |
939 |
|
if (f == null) throw new NullPointerException(); |
940 |
|
CompletableFuture<T> d = newIncompleteFuture(); |
941 |
< |
if (!d.uniExceptionally(this, f, null)) { |
942 |
< |
UniExceptionally<T> c = new UniExceptionally<T>(d, this, f); |
939 |
< |
push(c); |
940 |
< |
c.tryFire(SYNC); |
941 |
< |
} |
941 |
> |
if (!d.uniExceptionally(this, f, null)) |
942 |
> |
unipush(new UniExceptionally<T>(d, this, f)); |
943 |
|
return d; |
944 |
|
} |
945 |
|
|
972 |
|
if ((r = result) != null) |
973 |
|
d.completeRelay(r); |
974 |
|
else { |
975 |
< |
UniRelay<T> c = new UniRelay<T>(d, this); |
975 |
< |
push(c); |
976 |
< |
c.tryFire(SYNC); |
975 |
> |
unipush(new UniRelay<T>(d, this)); |
976 |
|
} |
977 |
|
return d; |
978 |
|
} |
982 |
|
if ((r = result) != null) |
983 |
|
return new MinimalStage<T>(encodeRelay(r)); |
984 |
|
MinimalStage<T> d = new MinimalStage<T>(); |
985 |
< |
UniRelay<T> c = new UniRelay<T>(d, this); |
987 |
< |
push(c); |
988 |
< |
c.tryFire(SYNC); |
985 |
> |
unipush(new UniRelay<T>(d, this)); |
986 |
|
return d; |
987 |
|
} |
988 |
|
|
1025 |
|
@SuppressWarnings("unchecked") S s = (S) r; |
1026 |
|
CompletableFuture<T> g = f.apply(s).toCompletableFuture(); |
1027 |
|
if (g.result == null || !uniRelay(g)) { |
1028 |
< |
UniRelay<T> copy = new UniRelay<T>(this, g); |
1032 |
< |
g.push(copy); |
1033 |
< |
copy.tryFire(SYNC); |
1028 |
> |
g.unipush(new UniRelay<T>(this, g)); |
1029 |
|
if (result == null) |
1030 |
|
return false; |
1031 |
|
} |
1055 |
|
if ((s = g.result) != null) |
1056 |
|
d.completeRelay(s); |
1057 |
|
else { |
1058 |
< |
UniRelay<V> c = new UniRelay<V>(d, g); |
1064 |
< |
g.push(c); |
1065 |
< |
c.tryFire(SYNC); |
1058 |
> |
g.unipush(new UniRelay<V>(d, g)); |
1059 |
|
} |
1060 |
|
return d; |
1061 |
|
} catch (Throwable ex) { |
1063 |
|
return d; |
1064 |
|
} |
1065 |
|
} |
1073 |
– |
UniCompose<T,V> c = new UniCompose<T,V>(e, d, this, f); |
1066 |
|
if (r != null && e != null) { |
1067 |
|
try { |
1068 |
|
e.execute(new UniCompose<T,V>(null, d, this, f)); |
1071 |
|
} |
1072 |
|
} |
1073 |
|
else { |
1074 |
< |
push(c); |
1083 |
< |
c.tryFire(SYNC); |
1074 |
> |
unipush(new UniCompose<T,V>(e, d, this, f)); |
1075 |
|
} |
1076 |
|
return d; |
1077 |
|
} |