private void clear() {
        this.completedSends.clear();
        this.completedReceives.clear();
        this.connected.clear();
        this.disconnected.clear();

        // Remove closed channels after all their buffered receives have been processed or if a send was requested
        for (Iterator<Map.Entry<String, KafkaChannel>> it = closingChannels.entrySet().iterator(); it.hasNext(); ) {
            KafkaChannel channel = it.next().getValue();
            boolean sendFailed = failedSends.remove(channel.id());
            boolean hasPending = false;
            if (!sendFailed)
                hasPending = maybeReadFromClosingChannel(channel);
            if (!hasPending) {
                doClose(channel, true);
                it.remove();
            }
        }

        for (String channel : this.failedSends)
            this.disconnected.put(channel, ChannelState.FAILED_SEND);
        this.failedSends.clear();
        this.madeReadProgressLastPoll = false;
    }
Clears all the results from the previous poll. This is invoked by Selector at the start of
a poll() when all the results from the previous poll are expected to have been handled.
<p>
SocketServer uses {@link #clearCompletedSends()} and {@link #clearCompletedReceives()} to
clear `completedSends` and `completedReceives` as soon as they are processed to avoid
holding onto large request/response buffers from multiple connections longer than necessary.
Clients rely on Selector invoking {@link #clear()} at the start of each poll() since memory usage
is less critical and clearing once-per-poll provides the flexibility to process these results in
any order before the next poll.
clients/src/main/java/org/apache/kafka/common/network/Selector.java