Class SimpleLeakAwareByteBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.WrappedByteBuf
-
- io.netty.buffer.SimpleLeakAwareByteBuf
-
- All Implemented Interfaces:
ReferenceCounted
,java.lang.Comparable<ByteBuf>
- Direct Known Subclasses:
AdvancedLeakAwareByteBuf
class SimpleLeakAwareByteBuf extends WrappedByteBuf
-
-
Field Summary
Fields Modifier and Type Field Description (package private) ResourceLeakTracker<ByteBuf>
leak
private ByteBuf
trackedByteBuf
This object's is associated with theResourceLeakTracker
.-
Fields inherited from class io.netty.buffer.WrappedByteBuf
buf
-
-
Constructor Summary
Constructors Constructor Description SimpleLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leak)
SimpleLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBuf
asReadOnly()
Returns a read-only version of this buffer.private void
closeLeak()
ByteBuf
duplicate()
Returns a buffer which shares the whole region of this buffer.protected SimpleLeakAwareByteBuf
newLeakAwareByteBuf(ByteBuf buf, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leakTracker)
private SimpleLeakAwareByteBuf
newLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leakTracker)
private SimpleLeakAwareByteBuf
newSharedLeakAwareByteBuf(ByteBuf wrapped)
ByteBuf
order(java.nio.ByteOrder endianness)
Returns a buffer with the specifiedendianness
which shares the whole region, indexes, and marks of this buffer.ByteBuf
readRetainedSlice(int length)
Returns a new retained slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by the size of the new slice (=length
).ByteBuf
readSlice(int length)
Returns a new slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by the size of the new slice (=length
).boolean
release()
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.boolean
release(int decrement)
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.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.ByteBuf
slice()
Returns a slice of this buffer's readable bytes.ByteBuf
slice(int index, int length)
Returns a slice of this buffer's sub-region.ByteBuf
touch()
Records the current access location of this object for debugging purposes.ByteBuf
touch(java.lang.Object hint)
Records the current access location of this object with an additional arbitrary information for debugging purposes.private ByteBuf
unwrappedDerived(ByteBuf derived)
private static ByteBuf
unwrapSwapped(ByteBuf buf)
-
Methods inherited from class io.netty.buffer.WrappedByteBuf
alloc, array, arrayOffset, bytesBefore, bytesBefore, bytesBefore, capacity, capacity, clear, compareTo, copy, copy, discardReadBytes, 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, internalNioBuffer, isAccessible, isContiguous, isDirect, isReadable, isReadable, isReadOnly, isWritable, isWritable, markReaderIndex, markWriterIndex, maxCapacity, maxFastWritableBytes, maxWritableBytes, memoryAddress, nioBuffer, nioBuffer, nioBufferCount, nioBuffers, 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, readShort, readShortLE, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, refCnt, 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, toString, toString, toString, 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.ByteBuf
getDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
-
-
-
Field Detail
-
trackedByteBuf
private final ByteBuf trackedByteBuf
This object's is associated with theResourceLeakTracker
. WhenResourceLeakTracker.close(Object)
is called this object will be used as the argument. It is also assumed that this object is used whenResourceLeakDetector.track(Object)
is called to createleak
.
-
leak
final ResourceLeakTracker<ByteBuf> leak
-
-
Constructor Detail
-
SimpleLeakAwareByteBuf
SimpleLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leak)
-
SimpleLeakAwareByteBuf
SimpleLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak)
-
-
Method Detail
-
slice
public ByteBuf slice()
Description copied from class:ByteBuf
Returns 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 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 classWrappedByteBuf
-
retainedSlice
public ByteBuf 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 classWrappedByteBuf
-
retainedSlice
public ByteBuf retainedSlice(int index, int length)
Description copied from class:ByteBuf
Returns 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 modifyreaderIndex
orwriterIndex
of 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:
retainedSlice
in classWrappedByteBuf
-
retainedDuplicate
public ByteBuf retainedDuplicate()
Description copied from class:ByteBuf
Returns 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 modifyreaderIndex
orwriterIndex
of 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:
retainedDuplicate
in classWrappedByteBuf
-
readRetainedSlice
public ByteBuf readRetainedSlice(int length)
Description copied from class:ByteBuf
Returns a new retained slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by 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:
readRetainedSlice
in classWrappedByteBuf
- Parameters:
length
- the size of the new slice- Returns:
- the newly created slice
-
slice
public ByteBuf slice(int index, int length)
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 classWrappedByteBuf
-
duplicate
public ByteBuf duplicate()
Description copied from class:ByteBuf
Returns 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 modifyreaderIndex
orwriterIndex
of 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:
duplicate
in classWrappedByteBuf
- 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.
-
readSlice
public ByteBuf readSlice(int length)
Description copied from class:ByteBuf
Returns a new slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by 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:
readSlice
in classWrappedByteBuf
- Parameters:
length
- the size of the new slice- Returns:
- the newly created slice
-
asReadOnly
public ByteBuf asReadOnly()
Description copied from class:ByteBuf
Returns a read-only version of this buffer.- Overrides:
asReadOnly
in classWrappedByteBuf
-
touch
public ByteBuf touch()
Description copied from interface:ReferenceCounted
Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
. This method is a shortcut totouch(null)
.- Specified by:
touch
in interfaceReferenceCounted
- Overrides:
touch
in classWrappedByteBuf
-
touch
public ByteBuf touch(java.lang.Object hint)
Description copied from interface:ReferenceCounted
Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
.- Specified by:
touch
in interfaceReferenceCounted
- Overrides:
touch
in classWrappedByteBuf
-
release
public boolean release()
Description copied from interface:ReferenceCounted
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Overrides:
release
in classWrappedByteBuf
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
release
public boolean release(int decrement)
Description copied from interface:ReferenceCounted
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Overrides:
release
in classWrappedByteBuf
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
closeLeak
private void closeLeak()
-
order
public ByteBuf order(java.nio.ByteOrder endianness)
Description copied from class:ByteBuf
Returns a buffer with the specifiedendianness
which 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 specifiedendianness
is identical to this buffer's byte order, this method can returnthis
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
order
in classWrappedByteBuf
-
newSharedLeakAwareByteBuf
private SimpleLeakAwareByteBuf newSharedLeakAwareByteBuf(ByteBuf wrapped)
-
newLeakAwareByteBuf
private SimpleLeakAwareByteBuf newLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leakTracker)
-
newLeakAwareByteBuf
protected SimpleLeakAwareByteBuf newLeakAwareByteBuf(ByteBuf buf, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leakTracker)
-
-