Methods Summary |
---|
public synchronized int | addAndGet(int val)
size = size + (val);
return size;
|
public synchronized void | clear()
queue.clear();
size = 0;
|
public synchronized XByteBuffer | getBuffer(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 int | getMaxSize()
return maxSize;
|
public synchronized void | returnBuffer(XByteBuffer buffer)
if ( (size + buffer.getCapacity()) <= maxSize ) {
addAndGet(buffer.getCapacity());
queue.add(buffer);
}
|
public void | setMaxSize(int bytes)
this.maxSize = bytes;
|