Package com.google.inject.internal
Interface CycleDetectingLock<ID>
-
- Type Parameters:
ID
- Lock identification provided by the client, is returned unmodified to the client when lock cycle is detected to identify it. Only toString() needs to be implemented. Lock references this object internally, for the purposes of Garbage Collection you should not use heavy IDs. Lock is referenced by a lock factory as long as it's owned by a thread.
- All Known Implementing Classes:
CycleDetectingLock.CycleDetectingLockFactory.ReentrantCycleDetectingLock
interface CycleDetectingLock<ID>
Simplified version ofLock
that is special due to how it handles deadlocks detection.Is an inherent part of
SingletonScope
, moved into a upper level class due to its size and complexity.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CycleDetectingLock.CycleDetectingLockFactory<ID>
Wraps locks so they would never cause a deadlock.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.google.common.collect.ListMultimap<java.lang.Thread,ID>
lockOrDetectPotentialLocksCycle()
Takes a lock in a blocking fashion in case no potential deadlocks are detected.void
unlock()
Unlocks previously locked lock.
-
-
-
Method Detail
-
lockOrDetectPotentialLocksCycle
com.google.common.collect.ListMultimap<java.lang.Thread,ID> lockOrDetectPotentialLocksCycle()
Takes a lock in a blocking fashion in case no potential deadlocks are detected. If the lock was successfully owned, returns an empty map indicating no detected potential deadlocks.Otherwise, a map indicating threads involved in a potential deadlock are returned. Map is ordered by dependency cycle and lists locks for each thread that are part of the loop in order, the last lock in the list is the one that the thread is currently waiting for. Returned map is created atomically.
In case no cycle is detected performance is O(threads creating singletons), in case cycle is detected performance is O(singleton locks).
-
unlock
void unlock()
Unlocks previously locked lock.
-
-