@Override
    public long maximumTimeToWait(long currentTimeMs) {
        pollTimer.update(currentTimeMs);
        if (
            pollTimer.isExpired() ||
                (membershipManager.shouldHeartbeatNow() && !heartbeatRequestState.requestInFlight())
        ) {
            return 0L;
        }
        return Math.min(pollTimer.remainingMs() / 2, heartbeatRequestState.timeToNextHeartbeatMs(currentTimeMs));
    }
Returns the delay for which the application thread can safely wait before it should be responsive
to results from the request managers. For example, the subscription state can change when heartbeats
are sent, so blocking for longer than the heartbeat interval might mean the application thread is not
responsive to changes.

Similarly, we may have to unblock the application thread to send a `PollApplicationEvent` to make sure
our poll timer will not expire while we are polling.

<p>In the event that heartbeats are currently being skipped, this still returns the next heartbeat
delay rather than {@code Long.MAX_VALUE} so that the application thread remains responsive.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/HeartbeatRequestManager.java