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.interface CycleDetectingLock<ID>
Lock
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.
Modifier and Type | Interface and Description |
---|---|
static class |
CycleDetectingLock.CycleDetectingLockFactory<ID>
Wraps locks so they would never cause a deadlock.
|
Modifier and Type | Method and 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.
|
com.google.common.collect.ListMultimap<java.lang.Thread,ID> lockOrDetectPotentialLocksCycle()
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).
void unlock()