Code example for BlockingQueue

Methods: remainingCapacity

0
     * @return list of messages that were deleted to create additional space. 
     */ 
    public synchronized List<LogCatMessage> ensureSpace(int messageCount) {
        List<LogCatMessage> l = new ArrayList<LogCatMessage>(messageCount);
 
        while (mQ.remainingCapacity() < messageCount) {
            l.add(mQ.poll());
        } 
 
        return l;
    } 
 
    /** 
     * Returns the number of additional elements that this queue can 
     * ideally (in the absence of memory or resource constraints) 
     * accept without blocking. 
     * @return the remaining capacity 
     */ 
    public synchronized int remainingCapacity() { 
        return mQ.remainingCapacity();
    }