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
public abstract class AbstractReferenceCountable extends java.lang.Object implements ReferenceCountable
Implements a template forReferenceCountable
objects.
-
-
Constructor Summary
Constructors Constructor Description AbstractReferenceCountable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
disposeIfUnreferenced()
Dispose this instance if there are no more references to it.protected abstract void
disposeUnreferenced()
Dispose this instance, which is not referenced anymore.int
getNumReferences()
Tells the number of references on this instance.boolean
isDisposed()
Optional operation. Tell whether this instance has been disposed.void
noteDiscardedReference(boolean isDisposeIfUnreferenced)
Declare that a reference on this instance has been discarded.void
noteObtainedReference()
Declare that there is a new reference obtained on this instance.
-
-
-
Method Detail
-
disposeIfUnreferenced
public boolean disposeIfUnreferenced()
Description copied from interface:ReferenceCountable
Dispose this instance if there are no more references to it.- Specified by:
disposeIfUnreferenced
in 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:ReferenceCountable
Tells the number of references on this instance.- Specified by:
getNumReferences
in interfaceReferenceCountable
- Returns:
- the number of references
-
noteObtainedReference
public void noteObtainedReference()
Description copied from interface:ReferenceCountable
Declare that there is a new reference obtained on this instance.- Specified by:
noteObtainedReference
in interfaceReferenceCountable
-
noteDiscardedReference
public void noteDiscardedReference(boolean isDisposeIfUnreferenced)
Description copied from interface:ReferenceCountable
Declare that a reference on this instance has been discarded. Optionally, dispose this instance if there are no remaining references.- Specified by:
noteDiscardedReference
in interfaceReferenceCountable
- Parameters:
isDisposeIfUnreferenced
- whether to dispose this instance if there are no more references
-
isDisposed
public boolean isDisposed()
Description copied from interface:ReferenceCountable
Optional operation. Tell whether this instance has been disposed.- Specified by:
isDisposed
in interfaceReferenceCountable
- Returns:
- whether this instance has been disposed
-
-