Package io.netty.buffer
Class AbstractReferenceCountedByteBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.AbstractByteBuf
-
- io.netty.buffer.AbstractReferenceCountedByteBuf
-
- All Implemented Interfaces:
ReferenceCounted,java.lang.Comparable<ByteBuf>
- Direct Known Subclasses:
AbstractPooledDerivedByteBuf,CompositeByteBuf,FixedCompositeByteBuf,PooledByteBuf,ReadOnlyByteBufferBuf,UnpooledDirectByteBuf,UnpooledHeapByteBuf
public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf
Abstract base class forByteBufimplementations that count references.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractReferenceCountedByteBuf>AIF_UPDATERprivate intrefCntprivate static longREFCNT_FIELD_OFFSETprivate static ReferenceCountUpdater<AbstractReferenceCountedByteBuf>updater-
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractReferenceCountedByteBuf(int maxCapacity)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voiddeallocate()Called oncerefCnt()is equals 0.private booleanhandleRelease(boolean result)(package private) booleanisAccessible()Used internally byAbstractByteBuf.ensureAccessible()to try to guard against using the buffer after it was released (best-effort).intrefCnt()Returns the reference count of this object.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.protected voidresetRefCnt()An unsafe operation intended for use by a subclass that resets the reference count of the buffer to 1ByteBufretain()Increases the reference count by1.ByteBufretain(int increment)Increases the reference count by the specifiedincrement.protected voidsetRefCnt(int refCnt)An unsafe operation intended for use by a subclass that sets the reference count of the buffer directlyByteBuftouch()Records the current access location of this object for debugging purposes.ByteBuftouch(java.lang.Object hint)Records the current access location of this object with an additional arbitrary information for debugging purposes.-
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, isReadOnly, 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, retainedSlice, setBoolean, setByte, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setIndex0, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, skipBytes, slice, 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
alloc, array, arrayOffset, capacity, capacity, copy, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getDoubleLE, getFloatLE, hasArray, hasMemoryAddress, internalNioBuffer, isContiguous, isDirect, maxFastWritableBytes, memoryAddress, nioBuffer, nioBufferCount, nioBuffers, order, readDoubleLE, readFloatLE, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setDoubleLE, setFloatLE, unwrap, writeDoubleLE, writeFloatLE
-
-
-
-
Field Detail
-
REFCNT_FIELD_OFFSET
private static final long REFCNT_FIELD_OFFSET
-
AIF_UPDATER
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<AbstractReferenceCountedByteBuf> AIF_UPDATER
-
updater
private static final ReferenceCountUpdater<AbstractReferenceCountedByteBuf> updater
-
refCnt
private volatile int refCnt
-
-
Method Detail
-
isAccessible
boolean isAccessible()
Description copied from class:ByteBufUsed internally byAbstractByteBuf.ensureAccessible()to try to guard against using the buffer after it was released (best-effort).- Overrides:
isAccessiblein classByteBuf
-
refCnt
public int refCnt()
Description copied from interface:ReferenceCountedReturns the reference count of this object. If0, it means this object has been deallocated.
-
setRefCnt
protected final void setRefCnt(int refCnt)
An unsafe operation intended for use by a subclass that sets the reference count of the buffer directly
-
resetRefCnt
protected final void resetRefCnt()
An unsafe operation intended for use by a subclass that resets the reference count of the buffer to 1
-
retain
public ByteBuf retain()
Description copied from interface:ReferenceCountedIncreases the reference count by1.- Specified by:
retainin interfaceReferenceCounted- Specified by:
retainin classByteBuf
-
retain
public ByteBuf retain(int increment)
Description copied from interface:ReferenceCountedIncreases the reference count by the specifiedincrement.- Specified by:
retainin interfaceReferenceCounted- Specified by:
retainin classByteBuf
-
touch
public ByteBuf touch()
Description copied from interface:ReferenceCountedRecords 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:
touchin interfaceReferenceCounted- Specified by:
touchin classByteBuf
-
touch
public ByteBuf touch(java.lang.Object hint)
Description copied from interface:ReferenceCountedRecords 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:
touchin interfaceReferenceCounted- Specified by:
touchin classByteBuf
-
release
public boolean release()
Description copied from interface:ReferenceCountedDecreases the reference count by1and deallocates this object if the reference count reaches at0.- 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.- Returns:
trueif and only if the reference count became0and this object has been deallocated
-
handleRelease
private boolean handleRelease(boolean result)
-
deallocate
protected abstract void deallocate()
Called oncerefCnt()is equals 0.
-
-