|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ locks overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.services.locks
Class LockControl

java.lang.Objectorg.apache.derby.impl.services.locks.LockControl
- All Implemented Interfaces:
- Control
- public class LockControl
- extends java.lang.Object
- implements Control
- extends java.lang.Object
A LockControl contains a reference to the item being locked and doubly linked lists for the granted locks and the waiting locks.
MT - Mutable - Container object : single thread required
| Field Summary | |
private Lock |
firstGrant
This lock control uses an optimistic locking scheme. |
private java.util.List |
granted
|
private Lock |
lastPossibleSkip
|
private org.apache.derby.iapi.services.locks.Lockable |
ref
|
private java.util.List |
waiting
|
| Constructor Summary | |
private |
LockControl(LockControl copyFrom)
|
protected |
LockControl(Lock firstLock,
org.apache.derby.iapi.services.locks.Lockable ref)
|
| Method Summary | |
Lock |
addLock(LockSet ls,
java.lang.Object compatabilitySpace,
java.lang.Object qualifier)
Add a lock into this control, granted it if possible. |
private void |
addWaiter(java.util.List waiting,
Lock lockItem,
LockSet ls)
Add a lock request to a list of waiters. |
void |
addWaiters(java.util.Dictionary waiters)
Add the waiters of this lock into this Dictionary object. |
ActiveLock |
firstWaiter()
Return the first lock in the wait line, null if the line is empty. |
Lock |
getFirstGrant()
|
java.util.List |
getGranted()
|
(package private) java.util.List |
getGrants()
Return a Stack of the held locks (Lock objects) on this Lockable. |
Lock |
getLock(java.lang.Object compatabilitySpace,
java.lang.Object qualifier)
Find a granted lock matching this space and qualifier |
org.apache.derby.iapi.services.locks.Lockable |
getLockable()
Return the lockable object controlled by me. |
LockControl |
getLockControl()
|
(package private) ActiveLock |
getNextWaiter(ActiveLock item,
boolean remove,
LockSet ls)
Get the next waiting lock (if any). |
java.util.List |
getWaiting()
|
protected void |
giveUpWait(java.lang.Object item,
LockSet ls)
Give up waiting up on a lock |
(package private) void |
grant(Lock lockItem)
Grant this lock. |
boolean |
isEmpty()
|
boolean |
isGrantable(boolean noWaitersBeforeMe,
java.lang.Object compatabilitySpace,
java.lang.Object qualifier)
This routine can be called to see if a lock currently on the wait list could be granted. |
protected boolean |
isUnlocked()
|
private java.lang.Object |
popFrontWaiter(java.util.List waiting,
LockSet ls)
Remove and return the first lock request from a list of waiters. |
private java.lang.Object |
removeWaiter(java.util.List waiting,
int index,
LockSet ls)
Remove and return the lock request at the given index from a list of waiters. |
private int |
removeWaiter(java.util.List waiting,
java.lang.Object item,
LockSet ls)
Remove and return the given lock request from a list of waiters. |
Control |
shallowClone()
make a shallow clone of myself |
boolean |
unlock(org.apache.derby.iapi.services.locks.Latch lockInGroup,
int unlockCount)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
ref
private final org.apache.derby.iapi.services.locks.Lockable ref
firstGrant
private Lock firstGrant
- This lock control uses an optimistic locking scheme.
When the first lock on an object is granted it
simply sets firstGrant to be that object, removing the
need to allocate a list if no other locks are granted
before the first lock is release. If a second lock
is granted then a list is allocated and the
firstGrant lock is moved into the list. Once a list
has been created it is always used.
granted
private java.util.List granted
waiting
private java.util.List waiting
lastPossibleSkip
private Lock lastPossibleSkip
| Constructor Detail |
LockControl
protected LockControl(Lock firstLock, org.apache.derby.iapi.services.locks.Lockable ref)
LockControl
private LockControl(LockControl copyFrom)
| Method Detail |
getLockControl
public LockControl getLockControl()
- Specified by:
getLockControlin interfaceControl
isEmpty
public boolean isEmpty()
grant
void grant(Lock lockItem)
- Grant this lock.
unlock
public boolean unlock(org.apache.derby.iapi.services.locks.Latch lockInGroup, int unlockCount)
isGrantable
public boolean isGrantable(boolean noWaitersBeforeMe,
java.lang.Object compatabilitySpace,
java.lang.Object qualifier)
- This routine can be called to see if a lock currently on the wait
list could be granted. If this lock has waiters ahead of it
then we do not jump over the waiter(s) even if we can be granted.
This avoids the first waiter being starved out.
- Specified by:
isGrantablein interfaceControl
addLock
public Lock addLock(LockSet ls, java.lang.Object compatabilitySpace, java.lang.Object qualifier)
- Add a lock into this control, granted it if possible.
This can be entered in several states.
- The Lockable is locked (granted queue not empty), and there are no waiters (waiting queue is empty)
- The Lockable is locked and there are waiters
- The Lockable is locked and there are waiters and the first is potentially granted
- The Lockable is unlocked and there are waiters and the first is potentially granted. Logically the item is still locked, it's just that the lock has just been released and the first waker has not woken up yet. This call is never entered when the object is unlocked and there are no waiters. 1) The Lockable has just been unlocked,
isUnlocked
protected boolean isUnlocked()
firstWaiter
public ActiveLock firstWaiter()
- Return the first lock in the wait line, null if the
line is empty.
- Specified by:
firstWaiterin interfaceControl
getNextWaiter
ActiveLock getNextWaiter(ActiveLock item, boolean remove, LockSet ls)
- Get the next waiting lock (if any).
getLockable
public org.apache.derby.iapi.services.locks.Lockable getLockable()
- Return the lockable object controlled by me.
- Specified by:
getLockablein interfaceControl
getFirstGrant
public Lock getFirstGrant()
- Specified by:
getFirstGrantin interfaceControl
getGranted
public java.util.List getGranted()
- Specified by:
getGrantedin interfaceControl
getWaiting
public java.util.List getWaiting()
- Specified by:
getWaitingin interfaceControl
giveUpWait
protected void giveUpWait(java.lang.Object item, LockSet ls)
- Give up waiting up on a lock
addWaiters
public void addWaiters(java.util.Dictionary waiters)
- Add the waiters of this lock into this Dictionary object.
Each waiting thread gets two entries in the hashtable- key=compatibility space - value=ActiveLock
- key=ActiveLock - value={LockControl for first waiter|ActiveLock of previosue waiter}
- Specified by:
addWaitersin interfaceControl
getGrants
java.util.List getGrants()
- Return a Stack of the
held locks (Lock objects) on this Lockable.
getLock
public final Lock getLock(java.lang.Object compatabilitySpace, java.lang.Object qualifier)
shallowClone
public Control shallowClone()
- make a shallow clone of myself
- Specified by:
shallowClonein interfaceControl
addWaiter
private void addWaiter(java.util.List waiting, Lock lockItem, LockSet ls)
- Add a lock request to a list of waiters.
popFrontWaiter
private java.lang.Object popFrontWaiter(java.util.List waiting, LockSet ls)
- Remove and return the first lock request from a list of waiters.
removeWaiter
private java.lang.Object removeWaiter(java.util.List waiting, int index, LockSet ls)
- Remove and return the lock request at the given index
from a list of waiters.
removeWaiter
private int removeWaiter(java.util.List waiting, java.lang.Object item, LockSet ls)
- Remove and return the given lock request from a list of waiters.
|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> services >> [ locks overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.derby.impl.services.locks.LockControl