Class AbstractReferenceCountedByteBuf

java.lang.Object
io.netty.buffer.ByteBuf
io.netty.buffer.AbstractByteBuf
io.netty.buffer.AbstractReferenceCountedByteBuf
All Implemented Interfaces:
ByteBufConvertible, ReferenceCounted, Comparable<ByteBuf>
Direct Known Subclasses:
AbstractPooledDerivedByteBuf, AdaptivePoolingAllocator.AdaptiveByteBuf, CompositeByteBuf, FixedCompositeByteBuf, PooledByteBuf, ReadOnlyByteBufferBuf, UnpooledDirectByteBuf, UnpooledHeapByteBuf

public abstract class AbstractReferenceCountedByteBuf extends AbstractByteBuf
Abstract base class for ByteBuf implementations that count references.
  • Field Details

  • Constructor Details

    • AbstractReferenceCountedByteBuf

      protected AbstractReferenceCountedByteBuf(int maxCapacity)
  • Method Details

    • isAccessible

      boolean isAccessible()
      Description copied from class: ByteBuf
      Used internally by AbstractByteBuf.ensureAccessible() to try to guard against using the buffer after it was released (best-effort).
      Overrides:
      isAccessible in class ByteBuf
    • refCnt

      public int refCnt()
      Description copied from interface: ReferenceCounted
      Returns the reference count of this object. If 0, 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: ReferenceCounted
      Increases the reference count by 1.
      Specified by:
      retain in interface ReferenceCounted
      Specified by:
      retain in class ByteBuf
    • retain

      public ByteBuf retain(int increment)
      Description copied from interface: ReferenceCounted
      Increases the reference count by the specified increment.
      Specified by:
      retain in interface ReferenceCounted
      Specified by:
      retain in class ByteBuf
    • 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 via ResourceLeakDetector. This method is a shortcut to touch(null).
      Specified by:
      touch in interface ReferenceCounted
      Specified by:
      touch in class ByteBuf
    • touch

      public ByteBuf touch(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 via ResourceLeakDetector.
      Specified by:
      touch in interface ReferenceCounted
      Specified by:
      touch in class ByteBuf
    • release

      public boolean release()
      Description copied from interface: ReferenceCounted
      Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
      Returns:
      true if and only if the reference count became 0 and this object has been deallocated
    • release

      public boolean release(int decrement)
      Description copied from interface: ReferenceCounted
      Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
      Returns:
      true if and only if the reference count became 0 and this object has been deallocated
    • handleRelease

      private boolean handleRelease(boolean result)
    • deallocate

      protected abstract void deallocate()
      Called once refCnt() is equals 0.