FileDocCategorySizeDatePackage
BufferPool14Impl.javaAPI DocApache Tomcat 6.0.142185Fri Jul 20 04:20:30 BST 2007org.apache.catalina.tribes.io

BufferPool14Impl

public class BufferPool14Impl extends Object implements BufferPool.BufferPoolAPI
author
Filip Hanik
version
1.0

Fields Summary
protected int
maxSize
protected int
size
protected LinkedList
queue
Constructors Summary
Methods Summary
public synchronized intaddAndGet(int val)

        size = size + (val);
        return size;
    
public synchronized voidclear()

        queue.clear();
        size = 0;
    
public synchronized XByteBuffergetBuffer(int minSize, boolean discard)

        XByteBuffer buffer = (XByteBuffer)(queue.size()>0?queue.remove(0):null);
        if ( buffer != null ) addAndGet(-buffer.getCapacity());
        if ( buffer == null ) buffer = new XByteBuffer(minSize,discard);
        else if ( buffer.getCapacity() <= minSize ) buffer.expand(minSize);
        buffer.setDiscard(discard);
        buffer.reset();
        return buffer;
    
public intgetMaxSize()

        return maxSize;
    
public synchronized voidreturnBuffer(XByteBuffer buffer)

        if ( (size + buffer.getCapacity()) <= maxSize ) {
            addAndGet(buffer.getCapacity());
            queue.add(buffer);
        }
    
public voidsetMaxSize(int bytes)


        
        this.maxSize = bytes;