private boolean processAllResponses(final SimpleServerRpcConnection connection)
    throws IOException {
    // We want only one writer on the channel for a connection at a time.
    connection.responseWriteLock.lock();
    try {
      for (int i = 0; i < 20; i++) {
        // protection if some handlers manage to need all the responder
        RpcResponse resp = connection.responseQueue.pollFirst();
        if (resp == null) {
          return true;
        }
        if (!processResponse(connection, resp)) {
          connection.responseQueue.addFirst(resp);
          return false;
        }
      }
    } finally {
      connection.responseWriteLock.unlock();
    }

    return connection.responseQueue.isEmpty();
  }
Process all the responses for this connection
@return true if all the calls were processed or that someone else is doing it. false if there
        is still some work to do. In this case, we expect the caller to delay us.
hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServerResponder.java