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 always
0
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
Dispose this instance if there are no more references to it.int
Tells the number of references on this instance.default boolean
Optional operation. Tell whether this instance has been disposed.void
noteDiscardedReference
(boolean isDisposeIfUnreferenced) Declare that a reference on this instance has been discarded.void
Declare that there is a new reference obtained on this instance.
-
Method Details
-
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
-