Class ActiveLock
java.lang.Object
org.apache.derby.impl.services.locks.Lock
org.apache.derby.impl.services.locks.ActiveLock
A Lock represents a granted or waiting lock request.
MT - Mutable - Immutable identity : Thread Aware
MT - Mutable - Immutable identity : Thread Aware
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
If true then this lock can be granted even if it is not the first lock request on the wait queue.(package private) boolean
Set to true if the Lock potentially could be granted.(package private) byte
Set to true if the object waiting on this thread should wake up, MT - mutable - java synchronized(this) -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ActiveLock
(CompatibilitySpace space, Lockable ref, Object qualifier) Initialize the lock, should be seen as part of the constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Clear the potentially granted flag.protected boolean
Set the potentially granted flag, returns true if the flag changed its state.protected byte
waitForGrant
(int timeout) Wait for a lock to be granted, returns when the lock is granted.protected void
wakeUp
(byte why) Wake up anyone sleeping on this lock.Methods inherited from class org.apache.derby.impl.services.locks.Lock
addWaiters, copy, equals, firstWaiter, getCompatabilitySpace, getCount, getFirstGrant, getGranted, getLock, getLockable, getLockControl, getQualifier, getWaiting, grant, hashCode, isEmpty, isGrantable, shallowClone, unlock, unlock
-
Field Details
-
wakeUpNow
byte wakeUpNowSet to true if the object waiting on this thread should wake up, MT - mutable - java synchronized(this) -
potentiallyGranted
boolean potentiallyGrantedSet to true if the Lock potentially could be granted. MT - mutable - single thread required -
canSkip
protected boolean canSkipIf true then this lock can be granted even if it is not the first lock request on the wait queue. This can occur if the compatibility space already holds a lock on the object.
-
-
Constructor Details
-
ActiveLock
Initialize the lock, should be seen as part of the constructor. A future version of this class may become mutable - mutable identity. MT - single thread required
-
-
Method Details
-
setPotentiallyGranted
protected boolean setPotentiallyGranted()Set the potentially granted flag, returns true if the flag changed its state. MT - single thread required -
clearPotentiallyGranted
protected void clearPotentiallyGranted()Clear the potentially granted flag. MT - single thread required -
waitForGrant
Wait for a lock to be granted, returns when the lock is granted.The sleep wakeup scheme depends on the two booleans wakeUpNow and potentiallyGranted. MT - Single thread required - and assumed to be the thread requesting the lock.
- Returns:
- true if the wait ended early (ie. someone else woke us up).
- Throws:
StandardException
- timeout, deadlock or thread interrupted
-
wakeUp
protected void wakeUp(byte why) Wake up anyone sleeping on this lock. MT - Thread Safe
-