@Override
  public boolean offer(E e) {
    Objects.requireNonNull(e);

    lock.lock();
    try {
      if (queue.remainingCapacity() > 0) {
        this.queue.add(e);
        notEmpty.signal();
        return true;
      }
    } finally {
      lock.unlock();
    }
    return false;
  }
Creates a PriorityQueue with the specified capacity that orders its elements according to the
specified comparator.
@param capacity   the capacity of this queue
@param comparator the comparator that will be used to order this priority queue
hbase-server/src/main/java/org/apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java