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:
ReferenceCounted,java.lang.Comparable<ByteBuf>
- Direct Known Subclasses:
PooledDuplicatedByteBuf,PooledSlicedByteBuf
abstract class AbstractPooledDerivedByteBuf extends AbstractReferenceCountedByteBuf
Abstract base class for derivedByteBufimplementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAbstractPooledDerivedByteBuf.PooledNonRetainedDuplicateByteBufprivate static classAbstractPooledDerivedByteBuf.PooledNonRetainedSlicedByteBuf
-
Field Summary
Fields Modifier and Type Field Description private ByteBufparentDeallocations of a pooled derived buffer should always propagate through the entire chain of derived buffers.private ObjectPool.Handle<AbstractPooledDerivedByteBuf>recyclerHandleprivate AbstractByteBufrootParent-
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
-
Constructor Summary
Constructors Constructor Description AbstractPooledDerivedByteBuf(ObjectPool.Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ByteBufAllocatoralloc()Returns theByteBufAllocatorwhich created this buffer.byte[]array()Returns the backing byte array of this buffer.protected voiddeallocate()Called onceAbstractReferenceCountedByteBuf.refCnt()is equals 0.(package private) ByteBufduplicate0()booleanhasArray()Returnstrueif and only if this buffer has a backing byte array.booleanhasMemoryAddress()Returnstrueif 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>
Uinit(AbstractByteBuf unwrapped, ByteBuf wrapped, int readerIndex, int writerIndex, int maxCapacity)java.nio.ByteBufferinternalNioBuffer(int index, int length)Internal use only: Exposes the internal NIO buffer.booleanisContiguous()Returnstrueif thisByteBufimplementation is backed by a single memory region.booleanisDirect()Returnstrueif and only if this buffer is backed by an NIO direct buffer.booleanisReadOnly()Returnstrueif and only if this buffer is read-only.intnioBufferCount()Returns the maximum number of NIOByteBuffers that consist this buffer.java.nio.ByteOrderorder()Deprecated.(package private) voidparent(ByteBuf newParent)ByteBufretainedSlice()Returns a retained slice of this buffer's readable bytes.ByteBufslice(int index, int length)Returns a slice of this buffer's sub-region.AbstractByteBufunwrap()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, 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 Detail
-
recyclerHandle
private final ObjectPool.Handle<AbstractPooledDerivedByteBuf> recyclerHandle
-
rootParent
private AbstractByteBuf rootParent
-
parent
private ByteBuf 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 Detail
-
AbstractPooledDerivedByteBuf
AbstractPooledDerivedByteBuf(ObjectPool.Handle<? extends AbstractPooledDerivedByteBuf> recyclerHandle)
-
-
Method Detail
-
parent
final void parent(ByteBuf newParent)
-
unwrap
public final AbstractByteBuf unwrap()
Description copied from class:ByteBufReturn 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:AbstractReferenceCountedByteBufCalled onceAbstractReferenceCountedByteBuf.refCnt()is equals 0.- Specified by:
deallocatein classAbstractReferenceCountedByteBuf
-
alloc
public final ByteBufAllocator alloc()
Description copied from class:ByteBufReturns theByteBufAllocatorwhich created this buffer.
-
order
@Deprecated public final java.nio.ByteOrder order()
Deprecated.Description copied from class:ByteBufReturns the endianness of this buffer.
-
isReadOnly
public boolean isReadOnly()
Description copied from class:ByteBufReturnstrueif and only if this buffer is read-only.- Overrides:
isReadOnlyin classAbstractByteBuf
-
isDirect
public final boolean isDirect()
Description copied from class:ByteBufReturnstrueif and only if this buffer is backed by an NIO direct buffer.
-
hasArray
public boolean hasArray()
Description copied from class:ByteBufReturnstrueif 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:ByteBufReturns the backing byte array of this buffer.
-
hasMemoryAddress
public boolean hasMemoryAddress()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddressin classByteBuf
-
isContiguous
public boolean isContiguous()
Description copied from class:ByteBufReturnstrueif thisByteBufimplementation 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
falseby default, and afalsereturn value does not necessarily mean that the implementation is composite or that it is not backed by a single memory region.- Overrides:
isContiguousin classByteBuf
-
nioBufferCount
public final int nioBufferCount()
Description copied from class:ByteBufReturns the maximum number of NIOByteBuffers that consist this buffer. Note thatByteBuf.nioBuffers()orByteBuf.nioBuffers(int, int)might return a less number ofByteBuffers.- Specified by:
nioBufferCountin classByteBuf- Returns:
-1if this buffer has no underlyingByteBuffer. the number of the underlyingByteBuffers if this buffer has at least one underlyingByteBuffer. Note that this method does not return0to avoid confusion.- See Also:
ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int),ByteBuf.nioBuffers(),ByteBuf.nioBuffers(int, int)
-
internalNioBuffer
public final java.nio.ByteBuffer internalNioBuffer(int index, int length)Description copied from class:ByteBufInternal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBufferin classByteBuf
-
retainedSlice
public final ByteBuf retainedSlice()
Description copied from class:ByteBufReturns 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 modifyreaderIndexorwriterIndexof 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:
retainedSlicein classAbstractByteBuf
-
slice
public ByteBuf slice(int index, int length)
Description copied from class:ByteBufReturns 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 modifyreaderIndexorwriterIndexof this buffer.Also be aware that this method will NOT call
ByteBuf.retain()and so the reference count will NOT be increased.- Overrides:
slicein classAbstractByteBuf
-
duplicate0
final ByteBuf duplicate0()
-
-