Class AbstractRefCounted
java.lang.Object
org.opensearch.common.util.concurrent.AbstractRefCounted
- All Implemented Interfaces:
RefCounted
A basic RefCounted implementation that is initialized with a
ref count of 1 and calls
closeInternal() once it reaches
a 0 ref count- Opensearch.api:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected abstract voidfinal booleandecRef()Decreases the refCount of this instance.getName()gets the name of this instancefinal voidincRef()Increments the refCount of this instance.intrefCount()Returns the current reference count.final booleanTries to increment the refCount of this instance.
-
Constructor Details
-
AbstractRefCounted
-
-
Method Details
-
incRef
public final void incRef()Description copied from interface:RefCountedIncrements the refCount of this instance.- Specified by:
incRefin interfaceRefCounted- See Also:
-
tryIncRef
public final boolean tryIncRef()Description copied from interface:RefCountedTries to increment the refCount of this instance. This method will returntrueiff the refCount was- Specified by:
tryIncRefin interfaceRefCounted- See Also:
-
decRef
public final boolean decRef()Description copied from interface:RefCountedDecreases the refCount of this instance. If the refCount drops to 0, then this instance is considered as closed and should not be used anymore.- Specified by:
decRefin interfaceRefCounted- Returns:
- returns
trueif the ref count dropped to 0 as a result of calling this method - See Also:
-
alreadyClosed
protected void alreadyClosed() -
refCount
public int refCount()Returns the current reference count. -
getName
gets the name of this instance -
closeInternal
protected abstract void closeInternal()
-