| 864 | } |
| 865 | |
| 866 | abstract class Continuation<T, R> extends Promise<R> implements WaitQueue<T> { |
| 867 | |
| 868 | @Override |
| 869 | public final WaitQueue<T> add(final Continuation<T, ?> c) { |
| 870 | return new WaitQueueHeadTail<>(c, this); |
| 871 | } |
| 872 | |
| 873 | @Override |
| 874 | public final void forward(final Promise<T> target) { |
| 875 | target.continuation(this); |
| 876 | } |
| 877 | |
| 878 | @SuppressWarnings("unchecked") |
| 879 | @Override |
| 880 | public final void flush(final Future<T> result) { |
| 881 | Future<Object> r = (Future<Object>) result; |
| 882 | WaitQueue<Object> q = (Continuation<Object, Object>) this; |
| 883 | while (q instanceof Continuation) { |
| 884 | final Continuation<Object, Object> c = (Continuation<Object, Object>) q; |
| 885 | r = c.apply(r); |
| 886 | q = c.safeFlush(r); |
| 887 | } |
| 888 | if (q != null) |
| 889 | q.flush(r); |
| 890 | } |
| 891 | |
| 892 | abstract Future<R> apply(Future<T> result); |
| 893 | |
| 894 | @Override |
| 895 | protected String toStringPrefix() { |
| 896 | return "Continuation"; |
| 897 | } |
| 898 | } |
| 899 | |
| 900 | final class LinkedContinuation<T, R> { |
| 901 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…