Package org.apache.wayang.core.util
Interface ReferenceCountable
-
- All Known Subinterfaces:
ChannelInstance
,CompositeExecutionResource
,ExecutionResource
,Executor
,JavaChannelInstance
- All Known Implementing Classes:
AbstractChannelInstance
,AbstractReferenceCountable
,BroadcastChannel.Instance
,CollectionChannel.Instance
,DataSetChannel.Instance
,ExecutionResourceTemplate
,ExecutorTemplate
,FileChannel.Instance
,FlinkContextReference
,FlinkExecutor
,GenericJdbcExecutor
,GiraphExecutor
,JavaExecutor
,JdbcExecutor
,PushExecutorTemplate
,RddChannel.Instance
,SparkContextReference
,SparkExecutor
,SqlQueryChannel.Instance
,StreamChannel.Instance
,TensorChannel.Instance
,TensorflowContextReference
,TensorflowExecutor
public interface ReferenceCountable
This interface provides a reference-counting scheme, e.g., to manage allocated external resources. The initial number of references after the object instantiation is always0
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
disposeIfUnreferenced()
Dispose this instance if there are no more references to it.int
getNumReferences()
Tells the number of references on this instance.default 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
-
getNumReferences
int getNumReferences()
Tells the number of references on this instance.- Returns:
- the number of references
-
noteObtainedReference
void noteObtainedReference()
Declare that there is a new reference obtained on this instance.
-
noteDiscardedReference
void noteDiscardedReference(boolean isDisposeIfUnreferenced)
Declare that a reference on this instance has been discarded. Optionally, dispose this instance if there are no remaining references.- Parameters:
isDisposeIfUnreferenced
- whether to dispose this instance if there are no more references
-
disposeIfUnreferenced
boolean disposeIfUnreferenced()
Dispose this instance if there are no more references to it.- Returns:
- whether this instance is not referenced any more
-
isDisposed
default boolean isDisposed()
Optional operation. Tell whether this instance has been disposed.- Returns:
- whether this instance has been disposed
-
-