Class Monitor.Guard
- java.lang.Object
-
- com.google.common.util.concurrent.Monitor.Guard
-
- Direct Known Subclasses:
AbstractService.HasReachedRunningGuard
,AbstractService.IsStartableGuard
,AbstractService.IsStoppableGuard
,AbstractService.IsStoppedGuard
,ServiceManager.ServiceManagerState.AwaitHealthGuard
,ServiceManager.ServiceManagerState.StoppedGuard
- Enclosing class:
- Monitor
@Beta public abstract static class Monitor.Guard extends java.lang.Object
A boolean condition for which a thread may wait. AGuard
is associated with a singleMonitor
. The monitor may check the guard at arbitrary times from any thread occupying the monitor, so code should not be written to rely on how often a guard might or might not be checked.If a
Guard
is passed into any method of aMonitor
other than the one it is associated with, anIllegalMonitorStateException
is thrown.- Since:
- 10.0
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.locks.Condition
condition
(package private) Monitor
monitor
(package private) Monitor.Guard
next
The next active guard(package private) int
waiterCount
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract boolean
isSatisfied()
Evaluates this guard's boolean condition.
-
-
-
Field Detail
-
monitor
final Monitor monitor
-
condition
final java.util.concurrent.locks.Condition condition
-
waiterCount
int waiterCount
-
next
Monitor.Guard next
The next active guard
-
-
Constructor Detail
-
Guard
protected Guard(Monitor monitor)
-
-
Method Detail
-
isSatisfied
public abstract boolean isSatisfied()
Evaluates this guard's boolean condition. This method is always called with the associated monitor already occupied. Implementations of this method must depend only on state protected by the associated monitor, and must not modify that state.
-
-