Class AbstractReferenceCounted

java.lang.Object
io.netty.util.AbstractReferenceCounted
All Implemented Interfaces:
ReferenceCounted
Direct Known Subclasses:
AbstractDnsMessage, AbstractHttpData, AbstractMemcacheObject, ArrayRedisMessage, DefaultFileRegion, HAProxyMessage, MixedAttribute, MixedFileUpload, PemPrivateKey

public abstract class AbstractReferenceCounted extends Object implements ReferenceCounted
Abstract base class for classes wants to implement ReferenceCounted.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    Called once refCnt() is equals 0.
    int
    Returns the reference count of this object.
    boolean
    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.
    Increases the reference count by 1.
    retain(int increment)
    Increases the reference count by the specified increment.
    protected void
    setRefCnt(int refCnt)
    An unsafe operation intended for use by a subclass that sets the reference count of the object directly
    Records the current access location of this object for debugging purposes.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ReferenceCounted

    touch
  • Constructor Details

    • AbstractReferenceCounted

      public AbstractReferenceCounted()
  • Method Details

    • 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.
      Specified by:
      refCnt in interface ReferenceCounted
    • setRefCnt

      protected void setRefCnt(int refCnt)
      An unsafe operation intended for use by a subclass that sets the reference count of the object directly
    • retain

      public ReferenceCounted retain()
      Description copied from interface: ReferenceCounted
      Increases the reference count by 1.
      Specified by:
      retain in interface ReferenceCounted
    • retain

      public ReferenceCounted retain(int increment)
      Description copied from interface: ReferenceCounted
      Increases the reference count by the specified increment.
      Specified by:
      retain in interface ReferenceCounted
    • touch

      public ReferenceCounted 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
    • 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.
      Specified by:
      release in interface ReferenceCounted
      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.
      Specified by:
      release in interface ReferenceCounted
      Returns:
      true if and only if the reference count became 0 and this object has been deallocated
    • deallocate

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