Class CycleDetectingLockFactory.LockGraphNode
java.lang.Object
com.google.common.util.concurrent.CycleDetectingLockFactory.LockGraphNode
- Enclosing class:
CycleDetectingLockFactory
A
LockGraphNode
associated with each lock instance keeps track of the directed edges in
the lock acquisition graph.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Map
<CycleDetectingLockFactory.LockGraphNode, CycleDetectingLockFactory.ExampleStackTrace> The map tracking the locks that are known to be acquired before this lock, each associated with an example stack trace.(package private) final Map
<CycleDetectingLockFactory.LockGraphNode, CycleDetectingLockFactory.PotentialDeadlockException> The map tracking lock nodes that can cause a lock acquisition cycle if acquired before this node.(package private) final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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, List<CycleDetectingLockFactory.LockGraphNode> acquiredLocks) findPathTo
(CycleDetectingLockFactory.LockGraphNode node, 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) String
-
Field Details
-
allowedPriorLocks
final 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. Locks are weakly keyed to allow proper garbage collection when they are no longer referenced. -
disallowedPriorLocks
final Map<CycleDetectingLockFactory.LockGraphNode,CycleDetectingLockFactory.PotentialDeadlockException> disallowedPriorLocksThe map tracking lock nodes that can cause a lock acquisition cycle if acquired before this node. -
lockName
-
-
Constructor Details
-
LockGraphNode
LockGraphNode(String lockName)
-
-
Method Details
-
getLockName
String getLockName() -
checkAcquiredLocks
void checkAcquiredLocks(CycleDetectingLockFactory.Policy policy, 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
@CheckForNull private CycleDetectingLockFactory.ExampleStackTrace findPathTo(CycleDetectingLockFactory.LockGraphNode node, 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.
-