public int remainingCapacity() {
    lock.lock();
    try {
      return capacity - list.size();
    } finally {
      lock.unlock();
    }
  }
Returns the number of additional elements that this deque can ideally
(in the absence of memory or resource constraints) accept without
blocking. This is always equal to the initial capacity of this deque
less the current <pre>size</pre> of this deque.
<br>
Note that you <em>cannot</em> always tell if an attempt to insert
an element will succeed by inspecting <pre>remainingCapacity</pre>
because it may be the case that another thread is about to
insert or remove an element.
llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/PriorityBlockingDeque.java