FileDocCategorySizeDatePackage
BufferPool15Impl.javaAPI DocApache Tomcat 6.0.142139Fri Jul 20 04:20:32 BST 2007org.apache.catalina.tribes.io

BufferPool15Impl

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

Fields Summary
protected int
maxSize
protected AtomicInteger
size
protected ConcurrentLinkedQueue
queue
Constructors Summary
Methods Summary
public voidclear()

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

        XByteBuffer buffer = (XByteBuffer)queue.poll();
        if ( buffer != null ) size.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 voidreturnBuffer(XByteBuffer buffer)

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


        
        this.maxSize = bytes;