- java.lang.Object
-
- org.eclipse.jetty.io.RetainableByteBuffer
-
- All Implemented Interfaces:
org.eclipse.jetty.util.Retainable
public class RetainableByteBuffer extends java.lang.Object implements org.eclipse.jetty.util.RetainableA pooled ByteBuffer which maintains a reference count that is incremented with
retain()and decremented withrelease(). The buffer is released to the pool whenrelease()is called one more time thanretain().A
RetainableByteBuffercan either be:- in pool; in this case
isRetained()returnsfalseand callingrelease()throwsIllegalStateException - out of pool but not retained; in this case
isRetained()returnsfalseand callingrelease()returnstrue - out of pool and retained; in this case
isRetained()returnstrueand callingrelease()returnsfalse
Calling
release()on a out of pool and retained instance does not re-pool it while that re-pools it on a out of pool but not retained instance.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcapacity()voidclear()java.nio.ByteBuffergetBuffer()longgetLastUpdate()booleanhasRemaining()booleanisDirect()booleanisEmpty()booleanisRetained()booleanrelease()Decrements the retained counter of this buffer.intremaining()voidretain()Increments the retained counter of this buffer.java.lang.StringtoString()
-
-
-
Method Detail
-
capacity
public int capacity()
-
getBuffer
public java.nio.ByteBuffer getBuffer()
-
getLastUpdate
public long getLastUpdate()
-
isRetained
public boolean isRetained()
- Returns:
- true if this buffer is retained, false otherwise.
-
isDirect
public boolean isDirect()
-
retain
public void retain()
Increments the retained counter of this buffer.- Specified by:
retainin interfaceorg.eclipse.jetty.util.Retainable
-
release
public boolean release()
Decrements the retained counter of this buffer.- Returns:
- true if the buffer was re-pooled, false otherwise.
-
remaining
public int remaining()
-
hasRemaining
public boolean hasRemaining()
-
isEmpty
public boolean isEmpty()
-
clear
public void clear()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-