public void wakeup() {
        pendingTask.getAndUpdate(task -> {
            if (task == null) {
                return new WakeupFuture();
            } else if (task instanceof ActiveFuture) {
                ActiveFuture active = (ActiveFuture) task;
                boolean wasTriggered = active.future().completeExceptionally(new WakeupException());

                // If the Future was *already* completed when we invoke completeExceptionally, the WakeupException
                // will be ignored. If it was already completed, we then need to return a new WakeupFuture so that the
                // next call to setActiveTask will throw the WakeupException.
                return wasTriggered ? null : new WakeupFuture();
            } else if (task instanceof FetchAction) {
                FetchAction fetchAction = (FetchAction) task;
                fetchAction.fetchBuffer().wakeup();
                return new WakeupFuture();
            } else {
                return task;
            }
        });
    }
Wakeup a pending task.  If there isn't any pending task, return a WakeupFuture, so that the subsequent call
would know wakeup was previously called.
<p>
If there are active tasks, complete it with WakeupException, then unset pending task (return null here.
If the current task has already been woken-up, do nothing.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/WakeupTrigger.java