Class AbstractNonThreadSafeRefCounted

java.lang.Object
org.elasticsearch.compute.data.AbstractNonThreadSafeRefCounted
All Implemented Interfaces:
Closeable, AutoCloseable, RefCounted, Releasable
Direct Known Subclasses:
AbstractArrowBufBlock, AbstractArrowBufVector, AbstractDelegatingCompoundBlock, AggregateMetricDoubleArrayBlock, BooleanArrayBlock, BooleanArrayVector, BooleanBigArrayBlock, BooleanBigArrayVector, BooleanVectorBlock, BytesRefArrayBlock, BytesRefArrayVector, BytesRefVectorBlock, CompositeBlock, ConstantBooleanVector, ConstantBytesRefVector, ConstantDoubleVector, ConstantFloatVector, ConstantIntVector, ConstantLongVector, ConstantNullBlock, ConstantNullVector, DirectBytesRefVector, DocBlock, DocVector, DoubleArrayBlock, DoubleArrayVector, DoubleBigArrayBlock, DoubleBigArrayVector, DoubleVectorBlock, FloatArrayBlock, FloatArrayVector, FloatBigArrayBlock, FloatBigArrayVector, FloatVectorBlock, IntArrayBlock, IntArrayVector, IntBigArrayBlock, IntBigArrayVector, IntVectorBlock, LongArrayBlock, LongArrayVector, LongBigArrayBlock, LongBigArrayVector, LongRangeArrayBlock, LongVectorBlock, OrdinalBytesRefBlock, OrdinalBytesRefVector

public abstract class AbstractNonThreadSafeRefCounted extends Object implements RefCounted, Releasable
Releasable, non-threadsafe version of AbstractRefCounted. Calls to decRef() and close() are equivalent.
  • Constructor Details

    • AbstractNonThreadSafeRefCounted

      public AbstractNonThreadSafeRefCounted()
  • Method Details

    • incRef

      public final void incRef()
      Specified by:
      incRef in interface RefCounted
    • tryIncRef

      public final boolean tryIncRef()
      Specified by:
      tryIncRef in interface RefCounted
    • attachReleasable

      public final void attachReleasable(Releasable releasable)
      Attaches a Releasable that is invoked exactly once when this object's reference count reaches zero, immediately after closeInternal() completes. May be called at most once; throws IllegalStateException if called after release or a second time.
    • decRef

      public final boolean decRef()
      Specified by:
      decRef in interface RefCounted
    • hasReferences

      public final boolean hasReferences()
      Specified by:
      hasReferences in interface RefCounted
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Releasable
    • isReleased

      public final boolean isReleased()
    • closeInternal

      protected abstract void closeInternal()
      This is called when the number of references reaches zero. This is where resources should be released (adjusting circuit breakers if needed).