final class ConcurrentLockSet extends java.lang.Object implements LockTable
Lockable
s 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
Constructor and Description |
---|
ConcurrentLockSet(AbstractPool factory) |
Modifier and Type | Method and Description |
---|---|
void |
addWaiters(java.util.Map waiters)
Add all waiters in this lock table to a
Map object. |
boolean |
anyoneBlocked()
Check whether anyone is blocked.
|
int |
getWaitTimeout()
Get the wait timeout in milliseconds.
|
Lock |
lockObject(CompatibilitySpace compatibilitySpace,
Lockable ref,
java.lang.Object qualifier,
int timeout)
Lock an object within a specific compatibility space.
|
void |
oneLessWaiter()
Decrease blockCount by one.
|
void |
oneMoreWaiter()
Increase blockCount by one.
|
void |
setDeadlockTimeout(int timeout)
Set the deadlock timeout.
|
void |
setDeadlockTrace(boolean val)
Enable or disable tracing of deadlocks.
|
void |
setWaitTimeout(int timeout)
Set the wait timeout.
|
java.util.Map<Lockable,Control> |
shallowClone()
make a shallow clone of myself and my lock controls
|
void |
unlock(Latch item,
int unlockCount)
Unlock an object, previously locked by lockObject().
|
Lock |
unlockReference(CompatibilitySpace space,
Lockable ref,
java.lang.Object qualifier,
java.util.Map group)
Unlock an object once if it is present in the specified group.
|
boolean |
zeroDurationLockObject(CompatibilitySpace space,
Lockable ref,
java.lang.Object qualifier,
int timeout)
Lock an object and release the lock immediately.
|
ConcurrentLockSet(AbstractPool factory)
public Lock lockObject(CompatibilitySpace compatibilitySpace, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
lockObject
in interface LockTable
compatibilitySpace
- Compatibility space.ref
- Lockable reference.qualifier
- Qualifier.timeout
- Timeout in milli-secondsStandardException
- Standard Derby policy.public void unlock(Latch item, int unlockCount)
public Lock unlockReference(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier, java.util.Map group)
unlockReference
in interface LockTable
space
- the compatibility spaceref
- a reference to the locked objectqualifier
- qualifier of the lockgroup
- a map representing the locks in a groupnull
if
the object was not unlockedpublic boolean zeroDurationLockObject(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
Lock lock = lockTable.lockObject(space, ref, qualifier, timeout); lockTable.unlock(lock, 1);except that the implementation might be more efficient.
zeroDurationLockObject
in interface LockTable
space
- the compatibility spaceref
- a reference to the locked objectqualifier
- qualifier of the locktimeout
- maximum time to wait in milliseconds
(C_LockFactory.NO_WAIT
means don't wait)true
if the object was locked, or
false
if the object couldn't be locked immediately and timeout
was NO_WAIT
or LockOwner
had the noWait
flag setStandardException
- if the lock could not be obtainedpublic void setDeadlockTimeout(int timeout)
setDeadlockTimeout
in interface LockTable
timeout
- deadlock timeout in millisecondspublic void setWaitTimeout(int timeout)
setWaitTimeout
in interface LockTable
timeout
- wait timeout in millisecondspublic int getWaitTimeout()
getWaitTimeout
in interface LockTable
public void setDeadlockTrace(boolean val)
LockTable
setDeadlockTrace
in interface LockTable
val
- true
enables tracing, false
disables tracingpublic void addWaiters(java.util.Map waiters)
Map
object.
This method can only be called by the thread that is currently
performing deadlock detection. All entries that are visited in the lock
table will be locked when this method returns. The entries that have
been seen and locked will be unlocked after the deadlock detection has
finished.addWaiters
in interface LockTable
waiters
- the map to add the waiters toLockControl.addWaiters(java.util.Map)
public java.util.Map<Lockable,Control> shallowClone()
shallowClone
in interface LockTable
public void oneMoreWaiter()
oneMoreWaiter
in interface LockTable
public void oneLessWaiter()
oneLessWaiter
in interface LockTable
public boolean anyoneBlocked()
anyoneBlocked
in interface LockTable
true
if someone is blocked, false
otherwise