Class SimpleLeakAwareCompositeByteBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.AbstractByteBuf
-
- io.netty.buffer.AbstractReferenceCountedByteBuf
-
- io.netty.buffer.CompositeByteBuf
-
- io.netty.buffer.WrappedCompositeByteBuf
-
- io.netty.buffer.SimpleLeakAwareCompositeByteBuf
-
- All Implemented Interfaces:
ReferenceCounted,java.lang.Comparable<ByteBuf>,java.lang.Iterable<ByteBuf>
- Direct Known Subclasses:
AdvancedLeakAwareCompositeByteBuf
class SimpleLeakAwareCompositeByteBuf extends WrappedCompositeByteBuf
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty.buffer.CompositeByteBuf
CompositeByteBuf.ByteWrapper<T>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ResourceLeakTracker<ByteBuf>leak-
Fields inherited from class io.netty.buffer.CompositeByteBuf
BYTE_ARRAY_WRAPPER, BYTE_BUFFER_WRAPPER
-
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
-
Constructor Summary
Constructors Constructor Description SimpleLeakAwareCompositeByteBuf(CompositeByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufasReadOnly()Returns a read-only version of this buffer.private voidcloseLeak(ByteBuf trackedByteBuf)ByteBufduplicate()Returns a buffer which shares the whole region of this buffer.private SimpleLeakAwareByteBufnewLeakAwareByteBuf(ByteBuf wrapped)protected SimpleLeakAwareByteBufnewLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leakTracker)ByteBuforder(java.nio.ByteOrder endianness)Returns a buffer with the specifiedendiannesswhich shares the whole region, indexes, and marks of this buffer.ByteBufreadRetainedSlice(int length)Returns a new retained slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).ByteBufreadSlice(int length)Returns a new slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).booleanrelease()Decreases the reference count by1and deallocates this object if the reference count reaches at0.booleanrelease(int decrement)Decreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.ByteBufretainedDuplicate()Returns a retained buffer which shares the whole region of this buffer.ByteBufretainedSlice()Returns a retained slice of this buffer's readable bytes.ByteBufretainedSlice(int index, int length)Returns a retained slice of this buffer's sub-region.ByteBufslice()Returns a slice of this buffer's readable bytes.ByteBufslice(int index, int length)Returns a slice of this buffer's sub-region.-
Methods inherited from class io.netty.buffer.WrappedCompositeByteBuf
_getByte, _getInt, _getIntLE, _getLong, _getLongLE, _getShort, _getShortLE, _getUnsignedMedium, _getUnsignedMediumLE, _setByte, _setInt, _setIntLE, _setLong, _setLongLE, _setMedium, _setMediumLE, _setShort, _setShortLE, addComponent, addComponent, addComponent, addComponent, addComponents, addComponents, addComponents, addComponents, addComponents, addComponents, addFlattenedComponents, alloc, array, arrayOffset, bytesBefore, bytesBefore, bytesBefore, capacity, capacity, clear, compareTo, component, componentAtOffset, consolidate, consolidate, copy, copy, deallocate, decompose, discardReadBytes, discardReadComponents, discardSomeReadBytes, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getInt, getIntLE, getLong, getLongLE, getMedium, getMediumLE, getShort, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMedium, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, hasArray, hashCode, hasMemoryAddress, indexOf, internalComponent, internalComponentAtOffset, internalNioBuffer, isAccessible, isDirect, isReadable, isReadable, isReadOnly, isWritable, isWritable, iterator, markReaderIndex, markWriterIndex, maxCapacity, maxFastWritableBytes, maxNumComponents, maxWritableBytes, memoryAddress, newSwappedByteBuf, nioBuffer, nioBuffer, nioBufferCount, nioBuffers, nioBuffers, numComponents, 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, readShort, readShortLE, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, refCnt, removeComponent, removeComponents, resetReaderIndex, resetWriterIndex, retain, retain, setBoolean, setByte, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, skipBytes, toByteIndex, toComponentIndex, toString, toString, toString, touch, touch, unwrap, 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.CompositeByteBuf
forEachByteAsc0, forEachByteDesc0
-
Methods inherited from class io.netty.buffer.AbstractReferenceCountedByteBuf
resetRefCnt, setRefCnt
-
Methods inherited from class io.netty.buffer.AbstractByteBuf
adjustMarkers, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, discardMarks, ensureAccessible, ensureWritable0, maxCapacity, setIndex0, trimIndicesToCapacity
-
Methods inherited from class io.netty.buffer.ByteBuf
getDoubleLE, getFloatLE, isContiguous, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
-
-
-
Field Detail
-
leak
final ResourceLeakTracker<ByteBuf> leak
-
-
Constructor Detail
-
SimpleLeakAwareCompositeByteBuf
SimpleLeakAwareCompositeByteBuf(CompositeByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak)
-
-
Method Detail
-
release
public boolean release()
Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Overrides:
releasein classWrappedCompositeByteBuf- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
release
public boolean release(int decrement)
Description copied from interface:ReferenceCountedDecreases the reference count by the specifieddecrementand deallocates this object if the reference count reaches at0.- Specified by:
releasein interfaceReferenceCounted- Overrides:
releasein classWrappedCompositeByteBuf- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
closeLeak
private void closeLeak(ByteBuf trackedByteBuf)
-
order
public ByteBuf order(java.nio.ByteOrder endianness)
Description copied from class:ByteBufReturns a buffer with the specifiedendiannesswhich shares the whole region, indexes, and marks of this buffer. Modifying the content, the indexes, or the marks of the returned buffer or this buffer affects each other's content, indexes, and marks. If the specifiedendiannessis identical to this buffer's byte order, this method can returnthis. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
orderin classWrappedCompositeByteBuf
-
slice
public ByteBuf slice()
Description copied from class:ByteBufReturns a 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.Also be aware that this method will NOT call
ByteBuf.retain()and so the reference count will NOT be increased.- Overrides:
slicein classWrappedCompositeByteBuf
-
retainedSlice
public 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 classWrappedCompositeByteBuf
-
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 classWrappedCompositeByteBuf
-
retainedSlice
public ByteBuf retainedSlice(int index, int length)
Description copied from class:ByteBufReturns a retained 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.Note that this method returns a retained buffer unlike
ByteBuf.slice(int, int). This method behaves similarly toslice(...).retain()except that this method may return a buffer implementation that produces less garbage.- Overrides:
retainedSlicein classWrappedCompositeByteBuf
-
duplicate
public ByteBuf duplicate()
Description copied from class:ByteBufReturns a buffer which shares the whole region of this buffer. 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.The reader and writer marks will not be duplicated. Also be aware that this method will NOT call
ByteBuf.retain()and so the reference count will NOT be increased.- Overrides:
duplicatein classWrappedCompositeByteBuf- Returns:
- A buffer whose readable content is equivalent to the buffer returned by
ByteBuf.slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.
-
retainedDuplicate
public ByteBuf retainedDuplicate()
Description copied from class:ByteBufReturns a retained buffer which shares the whole region of this buffer. 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(0, buf.capacity()). This method does not modifyreaderIndexorwriterIndexof this buffer.Note that this method returns a retained buffer unlike
ByteBuf.slice(int, int). This method behaves similarly toduplicate().retain()except that this method may return a buffer implementation that produces less garbage.- Overrides:
retainedDuplicatein classWrappedCompositeByteBuf
-
readSlice
public ByteBuf readSlice(int length)
Description copied from class:ByteBufReturns a new slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).Also be aware that this method will NOT call
ByteBuf.retain()and so the reference count will NOT be increased.- Overrides:
readSlicein classWrappedCompositeByteBuf- Parameters:
length- the size of the new slice- Returns:
- the newly created slice
-
readRetainedSlice
public ByteBuf readRetainedSlice(int length)
Description copied from class:ByteBufReturns a new retained slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).Note that this method returns a retained buffer unlike
ByteBuf.readSlice(int). This method behaves similarly toreadSlice(...).retain()except that this method may return a buffer implementation that produces less garbage.- Overrides:
readRetainedSlicein classWrappedCompositeByteBuf- Parameters:
length- the size of the new slice- Returns:
- the newly created slice
-
asReadOnly
public ByteBuf asReadOnly()
Description copied from class:ByteBufReturns a read-only version of this buffer.- Overrides:
asReadOnlyin classWrappedCompositeByteBuf
-
newLeakAwareByteBuf
private SimpleLeakAwareByteBuf newLeakAwareByteBuf(ByteBuf wrapped)
-
newLeakAwareByteBuf
protected SimpleLeakAwareByteBuf newLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leakTracker)
-
-