Package org.eclipse.jetty.io
Class RetainableByteBuffer
java.lang.Object
org.eclipse.jetty.io.RetainableByteBuffer
- All Implemented Interfaces:
Retainable
A pooled ByteBuffer which maintains a reference count that is
incremented with retain()
and decremented with release()
. The buffer
is released to the pool when release()
is called one more time than retain()
.
A RetainableByteBuffer
can either be:
- in pool; in this case
isRetained()
returnsfalse
and callingrelease()
throwsIllegalStateException
- out of pool but not retained; in this case
isRetained()
returnsfalse
and callingrelease()
returnstrue
- out of pool and retained; in this case
isRetained()
returnstrue
and 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 Details
-
capacity
public int capacity() -
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:
retain
in interfaceRetainable
-
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
-