abstract class PooledByteBuf<T> extends AbstractReferenceCountedByteBuf
Modifier and Type | Field and Description |
---|---|
private ByteBufAllocator |
allocator |
(package private) PoolThreadCache |
cache |
protected PoolChunk<T> |
chunk |
protected long |
handle |
protected int |
length |
(package private) int |
maxLength |
protected T |
memory |
protected int |
offset |
private Recycler.Handle<PooledByteBuf<T>> |
recyclerHandle |
private java.nio.ByteBuffer |
tmpNioBuf |
leakDetector, readerIndex, writerIndex
Modifier | Constructor and Description |
---|---|
protected |
PooledByteBuf(Recycler.Handle<? extends PooledByteBuf<T>> recyclerHandle,
int maxCapacity) |
Modifier and Type | Method and Description |
---|---|
ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
int |
capacity()
Returns the number of bytes (octets) this buffer can contain.
|
ByteBuf |
capacity(int newCapacity)
Adjusts the capacity of this buffer.
|
protected void |
deallocate()
Called once
AbstractReferenceCountedByteBuf.refCnt() is equals 0. |
protected int |
idx(int index) |
(package private) void |
init(PoolChunk<T> chunk,
long handle,
int offset,
int length,
int maxLength,
PoolThreadCache cache) |
private void |
init0(PoolChunk<T> chunk,
long handle,
int offset,
int length,
int maxLength,
PoolThreadCache cache) |
(package private) void |
initUnpooled(PoolChunk<T> chunk,
int length) |
protected java.nio.ByteBuffer |
internalNioBuffer() |
protected abstract java.nio.ByteBuffer |
newInternalNioBuffer(T memory) |
java.nio.ByteOrder |
order()
Returns the endianness
of this buffer.
|
private void |
recycle() |
ByteBuf |
retainedDuplicate()
Returns a retained buffer which shares the whole region of this buffer.
|
ByteBuf |
retainedSlice()
Returns a retained slice of this buffer's readable bytes.
|
ByteBuf |
retainedSlice(int index,
int length)
Returns a retained slice of this buffer's sub-region.
|
(package private) void |
reuse(int maxCapacity)
Method must be called before reuse this
PooledByteBufAllocator |
ByteBuf |
unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.
|
refCnt, release, release, retain, retain, setRefCnt, touch, touch
_getByte, _getInt, _getIntLE, _getLong, _getLongLE, _getShort, _getShortLE, _getUnsignedMedium, _getUnsignedMediumLE, _setByte, _setInt, _setIntLE, _setLong, _setLongLE, _setMedium, _setMediumLE, _setShort, _setShortLE, adjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkIndex, checkIndex, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardMarks, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getByte, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getInt, getIntLE, getLong, getLongLE, getMedium, getMediumLE, getShort, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMedium, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, hashCode, indexOf, isReadable, isReadable, isReadOnly, isWritable, isWritable, markReaderIndex, markWriterIndex, maxCapacity, maxCapacity, maxWritableBytes, newSwappedByteBuf, nioBuffer, nioBuffers, order, readableBytes, readBoolean, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readCharSequence, readDouble, readerIndex, readerIndex, readFloat, readInt, readIntLE, readLong, readLongLE, readMedium, readMediumLE, readRetainedSlice, readShort, readShortLE, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, resetReaderIndex, resetWriterIndex, setBoolean, setByte, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setIndex0, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, skipBytes, slice, slice, toString, toString, toString, writableBytes, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeCharSequence, writeDouble, writeFloat, writeInt, writeIntLE, writeLong, writeLongLE, writeMedium, writeMediumLE, writerIndex, writerIndex, writeShort, writeShortLE, writeZero
array, arrayOffset, copy, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, hasArray, hasMemoryAddress, internalNioBuffer, isDirect, memoryAddress, nioBuffer, nioBufferCount, nioBuffers, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes
private final Recycler.Handle<PooledByteBuf<T>> recyclerHandle
protected long handle
protected T memory
protected int offset
protected int length
int maxLength
PoolThreadCache cache
private java.nio.ByteBuffer tmpNioBuf
private ByteBufAllocator allocator
protected PooledByteBuf(Recycler.Handle<? extends PooledByteBuf<T>> recyclerHandle, int maxCapacity)
void init(PoolChunk<T> chunk, long handle, int offset, int length, int maxLength, PoolThreadCache cache)
private void init0(PoolChunk<T> chunk, long handle, int offset, int length, int maxLength, PoolThreadCache cache)
final void reuse(int maxCapacity)
PooledByteBufAllocator
public final int capacity()
ByteBuf
public final ByteBuf capacity(int newCapacity)
ByteBuf
newCapacity
is less than the current
capacity, the content of this buffer is truncated. If the newCapacity
is greater
than the current capacity, the buffer is appended with unspecified data whose length is
(newCapacity - currentCapacity)
.public final ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator
which created this buffer.public final java.nio.ByteOrder order()
ByteBuf
public final ByteBuf unwrap()
ByteBuf
public final ByteBuf retainedDuplicate()
ByteBuf
buf.slice(0, buf.capacity())
.
This method does not modify readerIndex
or writerIndex
of
this buffer.
Note that this method returns a retained buffer unlike ByteBuf.slice(int, int)
.
This method behaves similarly to duplicate().retain()
except that this method may return
a buffer implementation that produces less garbage.
retainedDuplicate
in class AbstractByteBuf
public final ByteBuf retainedSlice()
ByteBuf
buf.slice(buf.readerIndex(), buf.readableBytes())
.
This method does not modify readerIndex
or writerIndex
of
this buffer.
Note that this method returns a retained buffer unlike ByteBuf.slice()
.
This method behaves similarly to slice().retain()
except that this method may return
a buffer implementation that produces less garbage.
retainedSlice
in class AbstractByteBuf
public final ByteBuf retainedSlice(int index, int length)
ByteBuf
readerIndex
or writerIndex
of
this buffer.
Note that this method returns a retained buffer unlike ByteBuf.slice(int, int)
.
This method behaves similarly to slice(...).retain()
except that this method may return
a buffer implementation that produces less garbage.
retainedSlice
in class AbstractByteBuf
protected final java.nio.ByteBuffer internalNioBuffer()
protected abstract java.nio.ByteBuffer newInternalNioBuffer(T memory)
protected final void deallocate()
AbstractReferenceCountedByteBuf
AbstractReferenceCountedByteBuf.refCnt()
is equals 0.deallocate
in class AbstractReferenceCountedByteBuf
private void recycle()
protected final int idx(int index)