@Override
  public NetworkRequest take() throws InterruptedException {
    NetworkRequest nextRequest;
    if (useLifoMode()) {
      nextRequest = deque.pollLast();
    } else {
      nextRequest = deque.pollFirst();
    }
    if (nextRequest == null) {
      // If there are no requests in the queue, wait until a new request comes.
      nextRequest = deque.take();
    }
    return nextRequest;
  }
@return the head of the queue if operating in LIFO mode. Else, returns the tail of the queue.
ambry-network/src/main/java/com/github/ambry/network/AdaptiveLifoCoDelNetworkRequestQueue.java