Package io.grpc.internal
Class InUseStateAggregator<T>
- java.lang.Object
-
- io.grpc.internal.InUseStateAggregator<T>
-
- Direct Known Subclasses:
ManagedChannelImpl.IdleModeStateAggregator
@NotThreadSafe public abstract class InUseStateAggregator<T> extends java.lang.Object
Aggregates the in-use state of a set of objects.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<T>
inUseObjects
-
Constructor Summary
Constructors Constructor Description InUseStateAggregator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
anyObjectInUse(java.lang.Object... objects)
Returnstrue
if any of the given objects are in use.protected abstract void
handleInUse()
Called when the aggregated in-use state has changed to true, which means at least one object is in use.protected abstract void
handleNotInUse()
Called when the aggregated in-use state has changed to false, which means no object is in use.boolean
isInUse()
void
updateObjectInUse(T object, boolean inUse)
Update the in-use state of an object.
-
-
-
Field Detail
-
inUseObjects
private final java.util.Set<T> inUseObjects
-
-
Method Detail
-
updateObjectInUse
public final void updateObjectInUse(T object, boolean inUse)
Update the in-use state of an object. Initially no object is in use.This may call into
handleInUse()
orhandleNotInUse()
when appropriate.
-
isInUse
public final boolean isInUse()
-
anyObjectInUse
public final boolean anyObjectInUse(java.lang.Object... objects)
Returnstrue
if any of the given objects are in use.- Parameters:
objects
- The objects to consider.- Returns:
true
if any of the given objects are in use.
-
handleInUse
protected abstract void handleInUse()
Called when the aggregated in-use state has changed to true, which means at least one object is in use.
-
handleNotInUse
protected abstract void handleNotInUse()
Called when the aggregated in-use state has changed to false, which means no object is in use.
-
-