Package io.netty.buffer
Class AbstractPooledDerivedByteBuf
java.lang.Object
io.netty.buffer.ByteBuf
io.netty.buffer.AbstractByteBuf
io.netty.buffer.AbstractReferenceCountedByteBuf
io.netty.buffer.AbstractPooledDerivedByteBuf
- All Implemented Interfaces:
ByteBufConvertible
,ReferenceCounted
,Comparable<ByteBuf>
- Direct Known Subclasses:
PooledDuplicatedByteBuf
,PooledSlicedByteBuf
Abstract base class for derived
ByteBuf
implementations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ByteBuf
Deallocations of a pooled derived buffer should always propagate through the entire chain of derived buffers.private final Recycler.EnhancedHandle
<AbstractPooledDerivedByteBuf> private AbstractByteBuf
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractPooledDerivedByteBuf
(ObjectPool.Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle) -
Method Summary
Modifier and TypeMethodDescriptionfinal ByteBufAllocator
alloc()
Returns theByteBufAllocator
which created this buffer.byte[]
array()
Returns the backing byte array of this buffer.protected final void
Called onceAbstractReferenceCountedByteBuf.refCnt()
is equals 0.(package private) final ByteBuf
boolean
hasArray()
Returnstrue
if and only if this buffer has a backing byte array.boolean
Returnstrue
if and only if this buffer has a reference to the low-level memory address that points to the backing data.(package private) final <U extends AbstractPooledDerivedByteBuf>
Uinit
(AbstractByteBuf unwrapped, ByteBuf wrapped, int readerIndex, int writerIndex, int maxCapacity) final ByteBuffer
internalNioBuffer
(int index, int length) Internal use only: Exposes the internal NIO buffer.boolean
Returnstrue
if thisByteBuf
implementation is backed by a single memory region.final boolean
isDirect()
Returnstrue
if and only if this buffer is backed by an NIO direct buffer.boolean
Returnstrue
if and only if this buffer is read-only.final int
Returns the maximum number of NIOByteBuffer
s that consist this buffer.final ByteOrder
order()
Deprecated.(package private) final void
final ByteBuf
Returns a retained slice of this buffer's readable bytes.slice
(int index, int length) Returns a slice of this buffer's sub-region.final AbstractByteBuf
unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.Methods inherited from class io.netty.buffer.AbstractReferenceCountedByteBuf
isAccessible, refCnt, release, release, resetRefCnt, retain, retain, setRefCnt, touch, touch
Methods inherited from class io.netty.buffer.AbstractByteBuf
_getByte, _getInt, _getIntLE, _getLong, _getLongLE, _getShort, _getShortLE, _getUnsignedMedium, _getUnsignedMediumLE, _setByte, _setInt, _setIntLE, _setLong, _setLongLE, _setMedium, _setMediumLE, _setShort, _setShortLE, adjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardMarks, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable, ensureWritable, ensureWritable0, equals, forEachByte, forEachByte, forEachByteAsc0, forEachByteDesc, forEachByteDesc, forEachByteDesc0, 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, trimIndicesToCapacity, 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
Methods inherited from class io.netty.buffer.ByteBuf
arrayOffset, asByteBuf, capacity, capacity, copy, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getDoubleLE, getFloatLE, maxFastWritableBytes, memoryAddress, nioBuffer, nioBuffers, readDoubleLE, readFloatLE, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
Field Details
-
recyclerHandle
-
rootParent
-
parent
Deallocations of a pooled derived buffer should always propagate through the entire chain of derived buffers. This is because each pooled derived buffer maintains its own reference count and we should respect each one. If deallocations cause a release of the "root parent" then then we may prematurely release the underlying content before all the derived buffers have been released.
-
-
Constructor Details
-
AbstractPooledDerivedByteBuf
AbstractPooledDerivedByteBuf(ObjectPool.Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle)
-
-
Method Details
-
parent
-
unwrap
Description copied from class:ByteBuf
Return the underlying buffer instance if this buffer is a wrapper of another buffer. -
init
final <U extends AbstractPooledDerivedByteBuf> U init(AbstractByteBuf unwrapped, ByteBuf wrapped, int readerIndex, int writerIndex, int maxCapacity) -
deallocate
protected final void deallocate()Description copied from class:AbstractReferenceCountedByteBuf
Called onceAbstractReferenceCountedByteBuf.refCnt()
is equals 0.- Specified by:
deallocate
in classAbstractReferenceCountedByteBuf
-
alloc
Description copied from class:ByteBuf
Returns theByteBufAllocator
which created this buffer. -
order
Deprecated.Description copied from class:ByteBuf
Returns the endianness of this buffer. -
isReadOnly
public boolean isReadOnly()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer is read-only.- Overrides:
isReadOnly
in classAbstractByteBuf
-
isDirect
public final boolean isDirect()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer is backed by an NIO direct buffer. -
hasArray
public boolean hasArray()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer has a backing byte array. If this method returns true, you can safely callByteBuf.array()
andByteBuf.arrayOffset()
. -
array
public byte[] array()Description copied from class:ByteBuf
Returns the backing byte array of this buffer. -
hasMemoryAddress
public boolean hasMemoryAddress()Description copied from class:ByteBuf
Returnstrue
if and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddress
in classByteBuf
-
isContiguous
public boolean isContiguous()Description copied from class:ByteBuf
Returnstrue
if thisByteBuf
implementation is backed by a single memory region. Composite buffer implementations must return false even if they currently hold ≤ 1 components. For buffers that returntrue
, it's guaranteed that a successful call toByteBuf.discardReadBytes()
will increase the value ofByteBuf.maxFastWritableBytes()
by the currentreaderIndex
.This method will return
false
by default, and afalse
return value does not necessarily mean that the implementation is composite or that it is not backed by a single memory region.- Overrides:
isContiguous
in classByteBuf
-
nioBufferCount
public final int nioBufferCount()Description copied from class:ByteBuf
Returns the maximum number of NIOByteBuffer
s that consist this buffer. Note thatByteBuf.nioBuffers()
orByteBuf.nioBuffers(int, int)
might return a less number ofByteBuffer
s.- Specified by:
nioBufferCount
in classByteBuf
- Returns:
-1
if this buffer has no underlyingByteBuffer
. the number of the underlyingByteBuffer
s if this buffer has at least one underlyingByteBuffer
. Note that this method does not return0
to avoid confusion.- See Also:
-
internalNioBuffer
Description copied from class:ByteBuf
Internal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBuffer
in classByteBuf
-
retainedSlice
Description copied from class:ByteBuf
Returns a retained slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical tobuf.slice(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.Note that this method returns a retained buffer unlike
ByteBuf.slice()
. This method behaves similarly toslice().retain()
except that this method may return a buffer implementation that produces less garbage.- Overrides:
retainedSlice
in classAbstractByteBuf
-
slice
Description copied from class:ByteBuf
Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modifyreaderIndex
orwriterIndex
of this buffer.Also be aware that this method will NOT call
ByteBuf.retain()
and so the reference count will NOT be increased.- Overrides:
slice
in classAbstractByteBuf
-
duplicate0
-