|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.services.locks.LockSet
final class LockSet
A LockSet is a complete lock table. A lock table is a hash table keyed by a Lockable and with a LockControl as the data element.
A LockControl contains information about the locks held on a Lockable.
MT - Mutable - Container Object : All non-private methods of this class are
thread safe unless otherwise stated by their javadoc comments.
All searching of
the hashtable is performed using java synchroization(this).
The class creates ActiveLock and LockControl objects.
LockControl objects are never passed out of this class, All the methods of
LockControl are called while being synchronized on this, thus providing the
single threading that LockControl required.
Methods of Lockables are only called by this class or LockControl, and
always while being synchronized on this, thus providing the single
threading that Lockable requires.
LockControl
Field Summary | |
---|---|
private int |
blockCount
|
private int |
deadlockTimeout
Timeout for deadlocks, in ms. |
private boolean |
deadlockTrace
|
private SinglePool |
factory
|
private java.util.HashMap |
locks
Hash table which maps Lockable objects to
Lock s. |
private int |
waitTimeout
|
Constructor Summary | |
---|---|
protected |
LockSet(SinglePool factory)
|
Method Summary | |
---|---|
void |
addWaiters(java.util.Map waiters)
Add all waiters in this lock table to a Map object. |
boolean |
anyoneBlocked()
Check whether there are anyone blocked in the lock table. |
private Control |
getControl(Lockable ref)
Get the Control for an object in the lock table. |
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 |
shallowClone()
make a shallow clone of myself and my lock controls |
java.lang.String |
toDebugString()
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final SinglePool factory
private final java.util.HashMap locks
Lockable
objects to
Lock
s.
private int deadlockTimeout
private int waitTimeout
private boolean deadlockTrace
private int blockCount
Constructor Detail |
---|
protected LockSet(SinglePool factory)
Method Detail |
---|
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-seconds
StandardException
- Standard Derby policy.public void unlock(Latch item, int unlockCount)
unlock
in interface LockTable
item
- the lock to unlockunlockCount
- the number of times to unlock the item; or zero,
meaning take the unlock count from the itempublic 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 group
null
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 set
StandardException
- 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 java.lang.String toDebugString()
public void addWaiters(java.util.Map waiters)
Map
object.
LockSet
object.
addWaiters
in interface LockTable
waiters
- the map to add the waiters toLockControl.addWaiters(java.util.Map)
public java.util.Map shallowClone()
shallowClone
in interface LockTable
public void oneMoreWaiter()
LockSet
object.
oneMoreWaiter
in interface LockTable
public void oneLessWaiter()
LockSet
object.
oneLessWaiter
in interface LockTable
public boolean anyoneBlocked()
LockTable
anyoneBlocked
in interface LockTable
true
if someone is blocked, false
otherwiseprivate final Control getControl(Lockable ref)
Control
for an object in the lock table.
LockSet
object.
|
Built on Thu 2011-03-10 11:54:14+0000, from revision ??? | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |