Lockables to LockControl objects.
A LockControl contains information about the locks held on a Lockable.
MT - Mutable : All public methods of this class, except addWaiters, are
thread safe. addWaiters can only be called from the thread which performs
deadlock detection. Only one thread can perform deadlock detection at a
time.
The class creates ActiveLock and LockControl objects.
LockControl objects are never passed out of this class, All the methods of
LockControl are called while holding a ReentrantLock associated with the
Lockable controlled by the LockControl, thus providing the
single threading that LockControl required.
Methods of Lockables are only called by this class or LockControl, and
always while holding the corresponding ReentrantLock, thus providing the
single threading that Lockable requires.
LockControl
| Modifier and Type | Class and Description |
|---|---|
| private static class | ConcurrentLockSet.
Class representing an entry in the lock table. |
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicInteger | |
| private int | deadlockTimeout
Timeout for deadlocks, in ms. |
| private boolean | |
| private final AbstractPool | |
| private final ConcurrentHashMap | locks
Hash table which maps |
| private ArrayList | seenByDeadlockDetection
List containing all entries seen by the last call to
|
| private int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | addWaiters(Map<Object, Object>
the map to add the waiters to waiters)Implements org. Add all waiters in this lock table to a |
| public boolean | Returns: true if someone is blocked, false
otherwiseImplements org. Check whether anyone is blocked. |
| private Object[] | Returns: an object describing the deadlockthe entry in the lock table for the lock request that
triggered deadlock detection entry,the waiting lock waitingLock, byte the reason for waking up the waiter wakeupReason)Check whether there is a deadlock. |
| private ConcurrentLockSet. | |
| public int | getWaitTimeout()
Implements org. Get the wait timeout in milliseconds. |
| public Lock | Returns: Object that represents the lock.Compatibility space. compatibilitySpace, Lockable Lockable reference. ref, Object Qualifier. qualifier, int Timeout in milli-seconds timeout)Implements org. Lock an object within a specific compatibility space. |
| public void | oneLessWaiter()
Implements org. Decrease blockCount by one. |
| public void | oneMoreWaiter()
Implements org. Increase blockCount by one. |
| public void | setDeadlockTimeout(int
deadlock timeout in milliseconds timeout)Implements org. Set the deadlock timeout. |
| public void | setDeadlockTrace(boolean
true enables tracing, false
disables tracingImplements org. Enable or disable tracing of deadlocks. |
| public void | setWaitTimeout(int
wait timeout in milliseconds timeout)Implements org. Set the wait timeout. |
| public Map | shallowClone()
Implements org. make a shallow clone of myself and my lock controls |
| private String | |
| public void | unlock(Latch
the lock to unlock item, int the number of times to unlock the item; or zero,
meaning take the unlock count from the item unlockCount)Implements org. Unlock an object, previously locked by lockObject(). |
| private void | unlock(ConcurrentLockSet.
the entry in which the lock is contained (the current
thread must have locked the entry) entry,the item to unlock item, int the number of times to unlock the item (if zero, take
the unlock count from item) unlockCount)Unlock an object, previously locked by lockObject(). |
| public Lock | Returns: the corresponding lock in the group map, ornull if
the object was not unlockedthe compatibility space space, Lockable a reference to the locked object ref, Object qualifier of the lock qualifier, Map<K, V> a map representing the locks in a group group)Implements org. Unlock an object once if it is present in the specified group. |
| public boolean | zeroDurationLockObject(CompatibilitySpace
the compatibility space space, Lockable a reference to the locked object ref, Object qualifier of the lock qualifier, int maximum time to wait in milliseconds
( timeout)C_LockFactory.NO_WAIT means don't wait)Implements org. Lock an object and release the lock immediately. |
| blockCount | back to summary |
|---|---|
| private final AtomicInteger blockCount | |
| deadlockTimeout | back to summary |
|---|---|
| private int deadlockTimeout Timeout for deadlocks, in ms.
| |
| deadlockTrace | back to summary |
|---|---|
| private boolean deadlockTrace | |
| factory | back to summary |
|---|---|
| private final AbstractPool factory | |
| locks | back to summary |
|---|---|
| private final ConcurrentHashMap<Lockable, ConcurrentLockSet. Hash table which maps | |
| seenByDeadlockDetection | back to summary |
|---|---|
| private ArrayList<ConcurrentLockSet. List containing all entries seen by the last call to
| |
| waitTimeout | back to summary |
|---|---|
| private int waitTimeout | |
| ConcurrentLockSet | back to summary |
|---|---|
| pack-priv ConcurrentLockSet(AbstractPool factory) | |
| addWaiters | back to summary |
|---|---|
| public void addWaiters(Map<Object, Object> waiters) Implements org. Add all waiters in this lock table to a
| |
| anyoneBlocked | back to summary |
|---|---|
| public boolean anyoneBlocked() Implements org. Check whether anyone is blocked.
| |
| checkDeadlock | back to summary |
|---|---|
| private Object[] checkDeadlock(ConcurrentLockSet. Check whether there is a deadlock. Make sure that only one thread enters deadlock detection at a time.
| |
| getEntry | back to summary |
|---|---|
| private ConcurrentLockSet. Get an entry from the lock table. If no entry exists for the
| |
| getWaitTimeout | back to summary |
|---|---|
| public int getWaitTimeout() Implements org. Get the wait timeout in milliseconds. | |
| lockObject | back to summary |
|---|---|
| public Lock lockObject(CompatibilitySpace compatibilitySpace, Lockable ref, Object qualifier, int timeout) throws StandardException Implements org. Lock an object within a specific compatibility space.
| |
| oneLessWaiter | back to summary |
|---|---|
| public void oneLessWaiter() Implements org. Decrease blockCount by one. | |
| oneMoreWaiter | back to summary |
|---|---|
| public void oneMoreWaiter() Implements org. Increase blockCount by one. | |
| setDeadlockTimeout | back to summary |
|---|---|
| public void setDeadlockTimeout(int timeout) Implements org. Set the deadlock timeout.
| |
| setDeadlockTrace | back to summary |
|---|---|
| public void setDeadlockTrace(boolean val) Implements org. Doc from org. Enable or disable tracing of deadlocks.
| |
| setWaitTimeout | back to summary |
|---|---|
| public void setWaitTimeout(int timeout) Implements org. Set the wait timeout.
| |
| shallowClone | back to summary |
|---|---|
| public Map Implements org. make a shallow clone of myself and my lock controls
| |
| toDebugString | back to summary |
|---|---|
| private String toDebugString() | |
| unlock | back to summary |
|---|---|
| public void unlock(Latch item, int unlockCount) Implements org. Unlock an object, previously locked by lockObject(). If unlockCOunt is not zero then the lock will be unlocked that many times, otherwise the unlock count is taken from item.
| |
| unlock | back to summary |
|---|---|
| private void unlock(ConcurrentLockSet. Unlock an object, previously locked by lockObject().
| |
| unlockReference | back to summary |
|---|---|
| public Lock unlockReference(CompatibilitySpace space, Lockable ref, Object qualifier, Map<K, V> group) Implements org. Unlock an object once if it is present in the specified group. Also remove the object from the group.
| |
| zeroDurationLockObject | back to summary |
|---|---|
| public boolean zeroDurationLockObject(CompatibilitySpace space, Lockable ref, Object qualifier, int timeout) throws StandardException Implements org. Doc from org. Lock an object and release the lock immediately. Equivalent to Lock lock = lockTable.lockObject(space, ref, qualifier, timeout); lockTable.unlock(lock, 1);except that the implementation might be more efficient.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv Control | control
The lock control. |
| private Condition | deadlockDetection
Condition variable which prevents calls to |
| private final ReentrantLock | mutex
Mutex used to ensure single-threaded access to the LockControls. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | enterDeadlockDetection()
Notify that the lock request that is currently accessing the entry will be entering deadlock detection. |
| pack-priv void | exitDeadlockDetection()
Notify that the deadlock detection triggered by the current thread has finished. |
| pack-priv void | |
| pack-priv void | |
| pack-priv void |
| control | back to summary |
|---|---|
| pack-priv Control control The lock control. | |
| deadlockDetection | back to summary |
|---|---|
| private Condition deadlockDetection Condition variable which prevents calls to | |
| mutex | back to summary |
|---|---|
| private final ReentrantLock mutex Mutex used to ensure single-threaded access to the LockControls. To avoid Java deadlocks, no thread should ever hold the mutex of more than one entry. Excepted from this requirement is a thread which performs deadlock detection. During deadlock detection, a thread might hold several mutexes, but it is not allowed to hold any mutex when entering the deadlock detection. Only one thread is allowed to perform deadlock detection at a time. | |
| Entry | back to summary |
|---|---|
| private Entry() | |
| enterDeadlockDetection | back to summary |
|---|---|
| pack-priv void enterDeadlockDetection() Notify that the lock request that is currently accessing the entry will be entering deadlock detection. Unlock the entry to allow the current thread or other threads to lock the entry for deadlock detection, but set the condition variable to prevent regular locking of the entry. | |
| exitDeadlockDetection | back to summary |
|---|---|
| pack-priv void exitDeadlockDetection() Notify that the deadlock detection triggered by the current thread has finished. Re-lock the entry and notify any waiters that the deadlock detection has completed. | |
| lock | back to summary |
|---|---|
| pack-priv void lock() Lock the entry, ensuring exclusive access to the contained
| |
| lockForDeadlockDetection | back to summary |
|---|---|
| pack-priv void lockForDeadlockDetection() Lock the entry while performing deadlock detection. This method will
lock the entry even when | |
| unlock | back to summary |
|---|---|
| pack-priv void unlock() Unlock the entry, allowing other threads to lock and access the
contained | |