Package org.apache.wayang.core.util
Class AbstractReferenceCountable
java.lang.Object
org.apache.wayang.core.util.AbstractReferenceCountable
- All Implemented Interfaces:
ReferenceCountable
- Direct Known Subclasses:
ExecutionResourceTemplate,ExecutorTemplate
Implements a template for
ReferenceCountable objects.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDispose this instance if there are no more references to it.protected abstract voidDispose this instance, which is not referenced anymore.intTells the number of references on this instance.booleanOptional operation. Tell whether this instance has been disposed.voidnoteDiscardedReference(boolean isDisposeIfUnreferenced) Declare that a reference on this instance has been discarded.voidDeclare that there is a new reference obtained on this instance.
-
Constructor Details
-
AbstractReferenceCountable
public AbstractReferenceCountable()
-
-
Method Details
-
disposeIfUnreferenced
public boolean disposeIfUnreferenced()Description copied from interface:ReferenceCountableDispose this instance if there are no more references to it.- Specified by:
disposeIfUnreferencedin interfaceReferenceCountable- Returns:
- whether this instance is not referenced any more
-
disposeUnreferenced
protected abstract void disposeUnreferenced()Dispose this instance, which is not referenced anymore. This method should always be invoked throughdisposeUnreferenced() -
getNumReferences
public int getNumReferences()Description copied from interface:ReferenceCountableTells the number of references on this instance.- Specified by:
getNumReferencesin interfaceReferenceCountable- Returns:
- the number of references
-
noteObtainedReference
public void noteObtainedReference()Description copied from interface:ReferenceCountableDeclare that there is a new reference obtained on this instance.- Specified by:
noteObtainedReferencein interfaceReferenceCountable
-
noteDiscardedReference
public void noteDiscardedReference(boolean isDisposeIfUnreferenced) Description copied from interface:ReferenceCountableDeclare that a reference on this instance has been discarded. Optionally, dispose this instance if there are no remaining references.- Specified by:
noteDiscardedReferencein interfaceReferenceCountable- Parameters:
isDisposeIfUnreferenced- whether to dispose this instance if there are no more references
-
isDisposed
public boolean isDisposed()Description copied from interface:ReferenceCountableOptional operation. Tell whether this instance has been disposed.- Specified by:
isDisposedin interfaceReferenceCountable- Returns:
- whether this instance has been disposed
-