Class Lock
- java.lang.Object
-
- org.apache.derby.impl.services.locks.Lock
-
- Direct Known Subclasses:
ActiveLock
class Lock extends java.lang.Object implements Latch, Control
A Lock represents a granted or waiting lock request.
MT - Mutable - Immutable identity : Thread Aware
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLock(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddWaiters(java.util.Map waiters)(package private) Lockcopy()booleanequals(java.lang.Object other)ActiveLockfirstWaiter()CompatibilitySpacegetCompatabilitySpace()Return the compatibility space this lock is held in.intgetCount()Return the count of locks.LockgetFirstGrant()java.util.ListgetGranted()LockgetLock(CompatibilitySpace compatibilitySpace, java.lang.Object qualifier)LockablegetLockable()Return the object this lock is held on MT - Thread safeLockControlgetLockControl()java.lang.ObjectgetQualifier()Return the qualifier lock was obtained with.java.util.ListgetWaiting()(package private) voidgrant()inthashCode()booleanisEmpty()booleanisGrantable(boolean noWaitersBeforeMe, CompatibilitySpace compatibilitySpace, java.lang.Object requestQualifier)ControlshallowClone()We can return ourselves here because our identity is immutable and what we returned will not be accessed as a Lock, so the count cannot be changed.(package private) intunlock(int unlockCount)booleanunlock(Latch lockInGroup, int unlockCount)
-
-
-
Field Detail
-
space
private final CompatibilitySpace space
Compatibility space the object is locked in. MT - immutable - reference only
-
ref
private final Lockable ref
Object being locked. MT - immutable - reference only
-
qualifier
private final java.lang.Object qualifier
Qualifier used in the lock request.. MT - immutable - reference only
-
count
int count
-
-
Constructor Detail
-
Lock
protected Lock(CompatibilitySpace space, Lockable ref, java.lang.Object qualifier)
-
-
Method Detail
-
getLockable
public final Lockable getLockable()
Return the object this lock is held on MT - Thread safe- Specified by:
getLockablein interfaceControl- Specified by:
getLockablein interfaceLatch
-
getCompatabilitySpace
public final CompatibilitySpace getCompatabilitySpace()
Return the compatibility space this lock is held in. MT - Thread safe- Specified by:
getCompatabilitySpacein interfaceLatch
-
getQualifier
public final java.lang.Object getQualifier()
Return the qualifier lock was obtained with. MT - Thread safe- Specified by:
getQualifierin interfaceLatch
-
getCount
public final int getCount()
Return the count of locks. MT - Thread safe
-
copy
final Lock copy()
-
grant
void grant()
-
unlock
int unlock(int unlockCount)
-
hashCode
public final int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public final boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
getLockControl
public LockControl getLockControl()
- Specified by:
getLockControlin interfaceControl
-
getLock
public Lock getLock(CompatibilitySpace compatibilitySpace, java.lang.Object qualifier)
-
shallowClone
public Control shallowClone()
We can return ourselves here because our identity is immutable and what we returned will not be accessed as a Lock, so the count cannot be changed.- Specified by:
shallowClonein interfaceControl
-
firstWaiter
public ActiveLock firstWaiter()
- Specified by:
firstWaiterin interfaceControl
-
unlock
public boolean unlock(Latch lockInGroup, int unlockCount)
-
addWaiters
public void addWaiters(java.util.Map waiters)
- Specified by:
addWaitersin 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
-
isGrantable
public boolean isGrantable(boolean noWaitersBeforeMe, CompatibilitySpace compatibilitySpace, java.lang.Object requestQualifier)- Specified by:
isGrantablein interfaceControl
-
-