Class CycleDetectingLockFactory.LockGraphNode
- java.lang.Object
-
- com.google.common.util.concurrent.CycleDetectingLockFactory.LockGraphNode
-
- Enclosing class:
- CycleDetectingLockFactory
private static class CycleDetectingLockFactory.LockGraphNode extends java.lang.ObjectALockGraphNodeassociated with each lock instance keeps track of the directed edges in the lock acquisition graph.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.Map<CycleDetectingLockFactory.LockGraphNode,CycleDetectingLockFactory.ExampleStackTrace>allowedPriorLocksThe map tracking the locks that are known to be acquired before this lock, each associated with an example stack trace.(package private) java.util.Map<CycleDetectingLockFactory.LockGraphNode,CycleDetectingLockFactory.PotentialDeadlockException>disallowedPriorLocksThe map tracking lock nodes that can cause a lock acquisition cycle if acquired before this node.(package private) java.lang.StringlockName
-
Constructor Summary
Constructors Constructor Description LockGraphNode(java.lang.String lockName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcheckAcquiredLock(CycleDetectingLockFactory.Policy policy, CycleDetectingLockFactory.LockGraphNode acquiredLock)Checks the acquisition-ordering betweenthis, which is about to be acquired, and the specifiedacquiredLock.(package private) voidcheckAcquiredLocks(CycleDetectingLockFactory.Policy policy, java.util.List<CycleDetectingLockFactory.LockGraphNode> acquiredLocks)private CycleDetectingLockFactory.ExampleStackTracefindPathTo(CycleDetectingLockFactory.LockGraphNode node, java.util.Set<CycleDetectingLockFactory.LockGraphNode> seen)Performs a depth-first traversal of the graph edges defined by each node'sallowedPriorLocksto find a path betweenthisand the specifiedlock.(package private) java.lang.StringgetLockName()
-
-
-
Field Detail
-
allowedPriorLocks
final java.util.Map<CycleDetectingLockFactory.LockGraphNode,CycleDetectingLockFactory.ExampleStackTrace> allowedPriorLocks
The map tracking the locks that are known to be acquired before this lock, each associated with an example stack trace. Locks are weakly keyed to allow proper garbage collection when they are no longer referenced.
-
disallowedPriorLocks
final java.util.Map<CycleDetectingLockFactory.LockGraphNode,CycleDetectingLockFactory.PotentialDeadlockException> disallowedPriorLocks
The map tracking lock nodes that can cause a lock acquisition cycle if acquired before this node.
-
lockName
final java.lang.String lockName
-
-
Method Detail
-
getLockName
java.lang.String getLockName()
-
checkAcquiredLocks
void checkAcquiredLocks(CycleDetectingLockFactory.Policy policy, java.util.List<CycleDetectingLockFactory.LockGraphNode> acquiredLocks)
-
checkAcquiredLock
void checkAcquiredLock(CycleDetectingLockFactory.Policy policy, CycleDetectingLockFactory.LockGraphNode acquiredLock)
Checks the acquisition-ordering betweenthis, which is about to be acquired, and the specifiedacquiredLock.When this method returns, the
acquiredLockshould be in either thepreAcquireLocksmap, for the case in which it is safe to acquirethisafter theacquiredLock, or in thedisallowedPriorLocksmap, in which case it is not safe.
-
findPathTo
private CycleDetectingLockFactory.ExampleStackTrace findPathTo(CycleDetectingLockFactory.LockGraphNode node, java.util.Set<CycleDetectingLockFactory.LockGraphNode> seen)
Performs a depth-first traversal of the graph edges defined by each node'sallowedPriorLocksto find a path betweenthisand the specifiedlock.- Returns:
- If a path was found, a chained
CycleDetectingLockFactory.ExampleStackTraceillustrating the path to thelock, ornullif no path was found.
-
-