Unblocks all threads and runs all listeners.
()
| 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. |
no test coverage detected