abstract class AbstractPooledDerivedByteBuf extends AbstractReferenceCountedByteBuf
ByteBuf
implementations.Modifier and Type | Class and Description |
---|---|
private static class |
AbstractPooledDerivedByteBuf.PooledNonRetainedDuplicateByteBuf |
private static class |
AbstractPooledDerivedByteBuf.PooledNonRetainedSlicedByteBuf |
Modifier and Type | Field and Description |
---|---|
private ByteBuf |
parent
Deallocations of a pooled derived buffer should always propagate through the entire chain of derived buffers.
|
private Recycler.Handle<AbstractPooledDerivedByteBuf> |
recyclerHandle |
private AbstractByteBuf |
rootParent |
leakDetector, readerIndex, writerIndex
Constructor and Description |
---|
AbstractPooledDerivedByteBuf(Recycler.Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle) |
Modifier and Type | Method and Description |
---|---|
ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
byte[] |
array()
Returns the backing byte array of this buffer.
|
protected void |
deallocate()
Called once
AbstractReferenceCountedByteBuf.refCnt() is equals 0. |
(package private) ByteBuf |
duplicate0() |
boolean |
hasArray()
Returns
true if and only if this buffer has a backing byte array. |
boolean |
hasMemoryAddress()
Returns
true if and only if this buffer has a reference to the low-level memory address that points
to the backing data. |
(package private) <U extends AbstractPooledDerivedByteBuf> |
init(AbstractByteBuf unwrapped,
ByteBuf wrapped,
int readerIndex,
int writerIndex,
int maxCapacity) |
java.nio.ByteBuffer |
internalNioBuffer(int index,
int length)
Internal use only: Exposes the internal NIO buffer.
|
boolean |
isDirect()
Returns
true if and only if this buffer is backed by an
NIO direct buffer. |
boolean |
isReadOnly()
Returns
true if and only if this buffer is read-only. |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffer s that consist this buffer. |
java.nio.ByteOrder |
order()
Deprecated.
|
(package private) void |
parent(ByteBuf newParent) |
ByteBuf |
retainedSlice()
Returns a retained slice of this buffer's readable bytes.
|
ByteBuf |
slice(int index,
int length)
Returns a slice of this buffer's sub-region.
|
AbstractByteBuf |
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, 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, retainedDuplicate, retainedSlice, setBoolean, setByte, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setIndex0, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, skipBytes, 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
private final Recycler.Handle<AbstractPooledDerivedByteBuf> recyclerHandle
private AbstractByteBuf rootParent
private ByteBuf parent
AbstractPooledDerivedByteBuf(Recycler.Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle)
final void parent(ByteBuf newParent)
public final AbstractByteBuf unwrap()
ByteBuf
final <U extends AbstractPooledDerivedByteBuf> U init(AbstractByteBuf unwrapped, ByteBuf wrapped, int readerIndex, int writerIndex, int maxCapacity)
protected final void deallocate()
AbstractReferenceCountedByteBuf
AbstractReferenceCountedByteBuf.refCnt()
is equals 0.deallocate
in class AbstractReferenceCountedByteBuf
public final ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator
which created this buffer.@Deprecated public final java.nio.ByteOrder order()
ByteBuf
public boolean isReadOnly()
ByteBuf
true
if and only if this buffer is read-only.isReadOnly
in class AbstractByteBuf
public final boolean isDirect()
ByteBuf
true
if and only if this buffer is backed by an
NIO direct buffer.public boolean hasArray()
ByteBuf
true
if and only if this buffer has a backing byte array.
If this method returns true, you can safely call ByteBuf.array()
and
ByteBuf.arrayOffset()
.public byte[] array()
ByteBuf
public boolean hasMemoryAddress()
ByteBuf
true
if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress
in class ByteBuf
public final int nioBufferCount()
ByteBuf
ByteBuffer
s that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int)
might return a less number of ByteBuffer
s.nioBufferCount
in class ByteBuf
-1
if this buffer has no underlying ByteBuffer
.
the number of the underlying ByteBuffer
s if this buffer has at least one underlying
ByteBuffer
. Note that this method does not return 0
to avoid confusion.ByteBuf.nioBuffer()
,
ByteBuf.nioBuffer(int, int)
,
ByteBuf.nioBuffers()
,
ByteBuf.nioBuffers(int, int)
public final java.nio.ByteBuffer internalNioBuffer(int index, int length)
ByteBuf
internalNioBuffer
in class ByteBuf
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 ByteBuf slice(int index, int length)
ByteBuf
readerIndex
or writerIndex
of
this buffer.
Also be aware that this method will NOT call ByteBuf.retain()
and so the
reference count will NOT be increased.
slice
in class AbstractByteBuf
final ByteBuf duplicate0()