Class AbstractRefCounted
- java.lang.Object
-
- org.elasticsearch.common.util.concurrent.AbstractRefCounted
-
- All Implemented Interfaces:
RefCounted
- Direct Known Subclasses:
RecoveryTarget,SearchContext
public abstract class AbstractRefCounted extends java.lang.Object implements RefCounted
A basic RefCounted implementation that is initialized with a ref count of 1 and callscloseInternal()once it reaches a 0 ref count
-
-
Constructor Summary
Constructors Constructor Description AbstractRefCounted(java.lang.String name)
-
Method Summary
Modifier and Type Method Description protected voidalreadyClosed()protected abstract voidcloseInternal()voiddecRef()Decreases the refCount of this instance.java.lang.StringgetName()gets the name of this instancevoidincRef()Increments the refCount of this instance.intrefCount()Returns the current reference count.booleantryIncRef()Tries to increment the refCount of this instance.
-
-
-
Method Detail
-
incRef
public final void incRef()
Description copied from interface:RefCountedIncrements the refCount of this instance.- Specified by:
incRefin interfaceRefCounted- See Also:
RefCounted.decRef(),RefCounted.tryIncRef()
-
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:
RefCounted.decRef(),RefCounted.incRef()
-
decRef
public final void 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- See Also:
RefCounted.incRef()
-
alreadyClosed
protected void alreadyClosed()
-
refCount
public int refCount()
Returns the current reference count.
-
getName
public java.lang.String getName()
gets the name of this instance
-
closeInternal
protected abstract void closeInternal()
-
-