MCPcopy Create free account
hub / github.com/antlr/codebuff / complete

Method complete

output/java_guava/1.4.17/AbstractFuture.java:770–792  ·  view source on GitHub ↗

Unblocks all threads and runs all listeners.

()

Source from the content-addressed store, hash-verified

768 /** Unblocks all threads and runs all listeners. */
769
770 private void complete() {
771 for (Waiter currentWaiter = clearWaiters(); currentWaiter != null; currentWaiter = currentWaiter.next) {
772 currentWaiter.unpark();
773 }
774 // We need to reverse the list to handle buggy listeners that depend on ordering.
775 Listener currentListener = clearListeners();
776 Listener reversedList = null;
777 while (currentListener != null) {
778 Listener tmp = currentListener;
779 currentListener = currentListener.next;
780 tmp.next = reversedList;
781 reversedList = tmp;
782 }
783 for (; reversedList != null; reversedList = reversedList.next) {
784 executeListener(reversedList.task, reversedList.executor);
785 }
786 // We call this after the listeners on the theory that afterDone() will only be used for
787 // 'cleanup' oriented tasks (e.g. clearing fields) and so can wait behind listeners which may be
788 // executing more important work. A counter argument would be that done() is trusted code and
789 // therefore it would be safe to run before potentially slow or poorly behaved listeners.
790 // Reevaluate this once we have more examples of afterDone() implementations.
791 afterDone();
792 }
793
794 /**
795 * Callback method that is called exactly once after the future is completed.

Callers 4

cancelMethod · 0.95
setMethod · 0.95
setExceptionMethod · 0.95
completeWithFutureMethod · 0.95

Calls 5

clearWaitersMethod · 0.95
unparkMethod · 0.95
clearListenersMethod · 0.95
executeListenerMethod · 0.95
afterDoneMethod · 0.95

Tested by

no test coverage detected