Class CycleDetectingLockFactory.LockGraphNode
- java.lang.Object
-
- com.google.common.util.concurrent.CycleDetectingLockFactory.LockGraphNode
-
- Enclosing class:
- CycleDetectingLockFactory
private static class CycleDetectingLockFactory.LockGraphNode extends java.lang.Object
ALockGraphNode
associated 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>
allowedPriorLocks
The 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>
disallowedPriorLocks
The map tracking lock nodes that can cause a lock acquisition cycle if acquired before this node.(package private) java.lang.String
lockName
-
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) void
checkAcquiredLock(CycleDetectingLockFactory.Policy policy, CycleDetectingLockFactory.LockGraphNode acquiredLock)
Checks the acquisition-ordering betweenthis
, which is about to be acquired, and the specifiedacquiredLock
.(package private) void
checkAcquiredLocks(CycleDetectingLockFactory.Policy policy, java.util.List<CycleDetectingLockFactory.LockGraphNode> acquiredLocks)
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'sallowedPriorLocks
to find a path betweenthis
and the specifiedlock
.(package private) java.lang.String
getLockName()
-
-
-
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
acquiredLock
should be in either thepreAcquireLocks
map, for the case in which it is safe to acquirethis
after theacquiredLock
, or in thedisallowedPriorLocks
map, 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'sallowedPriorLocks
to find a path betweenthis
and the specifiedlock
.- Returns:
- If a path was found, a chained
CycleDetectingLockFactory.ExampleStackTrace
illustrating the path to thelock
, ornull
if no path was found.
-
-