class SimpleLeakAwareByteBuf extends WrappedByteBuf
Modifier and Type | Field and Description |
---|---|
(package private) ResourceLeakTracker<ByteBuf> |
leak |
private ByteBuf |
trackedByteBuf
This object's is associated with the
ResourceLeakTracker . |
buf
Constructor and Description |
---|
SimpleLeakAwareByteBuf(ByteBuf wrapped,
ByteBuf trackedByteBuf,
ResourceLeakTracker<ByteBuf> leak) |
SimpleLeakAwareByteBuf(ByteBuf wrapped,
ResourceLeakTracker<ByteBuf> leak) |
Modifier and Type | Method and 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 specified
endianness 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 current
readerIndex and increases the readerIndex 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 current
readerIndex and increases the readerIndex by the size
of the new slice (= length ). |
boolean |
release()
Decreases the reference count by
1 and deallocates this object if the reference count reaches at
0 . |
boolean |
release(int decrement)
Decreases the reference count by the specified
decrement and deallocates this object if the reference
count reaches at 0 . |
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) |
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, isDirect, isReadable, isReadable, isReadOnly, isWritable, isWritable, markReaderIndex, markWriterIndex, maxCapacity, 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
private final ByteBuf trackedByteBuf
ResourceLeakTracker
. When ResourceLeakTracker.close(Object)
is called this object will be used as the argument. It is also assumed that this object is used when
ResourceLeakDetector.track(Object)
is called to create leak
.final ResourceLeakTracker<ByteBuf> leak
SimpleLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leak)
SimpleLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leak)
public ByteBuf slice()
ByteBuf
buf.slice(buf.readerIndex(), buf.readableBytes())
.
This method does not modify 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 WrappedByteBuf
public 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 WrappedByteBuf
public ByteBuf retainedSlice(int index, int length)
ByteBuf
readerIndex
or writerIndex
of
this buffer.
Note that this method returns a retained buffer unlike ByteBuf.slice(int, int)
.
This method behaves similarly to slice(...).retain()
except that this method may return
a buffer implementation that produces less garbage.
retainedSlice
in class WrappedByteBuf
public ByteBuf retainedDuplicate()
ByteBuf
buf.slice(0, buf.capacity())
.
This method does not modify readerIndex
or writerIndex
of
this buffer.
Note that this method returns a retained buffer unlike ByteBuf.slice(int, int)
.
This method behaves similarly to duplicate().retain()
except that this method may return
a buffer implementation that produces less garbage.
retainedDuplicate
in class WrappedByteBuf
public ByteBuf readRetainedSlice(int length)
ByteBuf
readerIndex
and increases the readerIndex
by the size
of the new slice (= length
).
Note that this method returns a retained buffer unlike ByteBuf.readSlice(int)
.
This method behaves similarly to readSlice(...).retain()
except that this method may return
a buffer implementation that produces less garbage.
readRetainedSlice
in class WrappedByteBuf
length
- the size of the new slicepublic 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 WrappedByteBuf
public ByteBuf duplicate()
ByteBuf
readerIndex
or writerIndex
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.
duplicate
in class WrappedByteBuf
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.public ByteBuf readSlice(int length)
ByteBuf
readerIndex
and increases the readerIndex
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.
readSlice
in class WrappedByteBuf
length
- the size of the new slicepublic ByteBuf asReadOnly()
ByteBuf
asReadOnly
in class WrappedByteBuf
public ByteBuf touch()
ReferenceCounted
ResourceLeakDetector
. This method is a shortcut to touch(null)
.touch
in interface ReferenceCounted
touch
in class WrappedByteBuf
public ByteBuf touch(java.lang.Object hint)
ReferenceCounted
ResourceLeakDetector
.touch
in interface ReferenceCounted
touch
in class WrappedByteBuf
public final boolean release()
ReferenceCounted
1
and deallocates this object if the reference count reaches at
0
.release
in interface ReferenceCounted
release
in class WrappedByteBuf
true
if and only if the reference count became 0
and this object has been deallocatedpublic final boolean release(int decrement)
ReferenceCounted
decrement
and deallocates this object if the reference
count reaches at 0
.release
in interface ReferenceCounted
release
in class WrappedByteBuf
true
if and only if the reference count became 0
and this object has been deallocatedprivate void closeLeak()
public ByteBuf order(java.nio.ByteOrder endianness)
ByteBuf
endianness
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
specified endianness
is identical to this buffer's byte order, this method can
return this
. This method does not modify readerIndex
or writerIndex
of this buffer.order
in class WrappedByteBuf
private SimpleLeakAwareByteBuf newSharedLeakAwareByteBuf(ByteBuf wrapped)
private SimpleLeakAwareByteBuf newLeakAwareByteBuf(ByteBuf wrapped, ResourceLeakTracker<ByteBuf> leakTracker)
protected SimpleLeakAwareByteBuf newLeakAwareByteBuf(ByteBuf buf, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leakTracker)