Class ConcurrentLockSet.Entry
- java.lang.Object
-
- org.apache.derby.impl.services.locks.ConcurrentLockSet.Entry
-
- Enclosing class:
- ConcurrentLockSet
private static final class ConcurrentLockSet.Entry extends java.lang.Object
Class representing an entry in the lock table.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Control
control
The lock control.private java.util.concurrent.locks.Condition
deadlockDetection
Condition variable which prevents calls tolock()
from locking the entry.private java.util.concurrent.locks.ReentrantLock
mutex
Mutex used to ensure single-threaded access to the LockControls.
-
Constructor Summary
Constructors Modifier Constructor Description private
Entry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
enterDeadlockDetection()
Notify that the lock request that is currently accessing the entry will be entering deadlock detection.(package private) void
exitDeadlockDetection()
Notify that the deadlock detection triggered by the current thread has finished.(package private) void
lock()
Lock the entry, ensuring exclusive access to the containedControl
object.(package private) void
lockForDeadlockDetection()
Lock the entry while performing deadlock detection.(package private) void
unlock()
Unlock the entry, allowing other threads to lock and access the containedControl
object.
-
-
-
Field Detail
-
control
Control control
The lock control.
-
mutex
private final java.util.concurrent.locks.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.
-
deadlockDetection
private java.util.concurrent.locks.Condition deadlockDetection
Condition variable which prevents calls tolock()
from locking the entry. If it is notnull
, only the thread performing deadlock detection may lock the entry (by callinglockForDeadlockDetection()
).
-
-
Method Detail
-
lock
void lock()
Lock the entry, ensuring exclusive access to the containedControl
object. The call will block until the entry can be locked. If the entry is unlocked anddeadlockDetection
is notnull
, the entry belongs to a thread which waits for deadlock detection to be initiated, and the call will block until that thread has finished its deadlock detection.
-
unlock
void unlock()
Unlock the entry, allowing other threads to lock and access the containedControl
object.
-
lockForDeadlockDetection
void lockForDeadlockDetection()
Lock the entry while performing deadlock detection. This method will lock the entry even whendeadlockDetection
is notnull
. IfdeadlockDetection
is notnull
, we know the entry and itsControl
will not be accessed by others until we have finished the deadlock detection, so it's OK for us to access it.
-
enterDeadlockDetection
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
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.
-
-