Top Description Fields Constructors Methods
org.apache.derby.impl.services.locks

public final Class ActiveLock

extends Lock
Class Inheritance
Imports
org.apache.derby.iapi.services.locks.CompatibilitySpace, .Lockable, .C_LockFactory, org.apache.derby.shared.common.error.StandardException

A Lock represents a granted or waiting lock request.
MT - Mutable - Immutable identity : Thread Aware

Field Summary

Modifier and TypeField and Description
protected boolean
canSkip

If true then this lock can be granted even if it is not the first lock request on the wait queue.

pack-priv boolean
potentiallyGranted

Set to true if the Lock potentially could be granted.

pack-priv byte
wakeUpNow

Set to true if the object waiting on this thread should wake up, MT - mutable - java synchronized(this)

Inherited from org.apache.derby.impl.services.locks.Lock:
count

Constructor Summary

AccessConstructor and Description
protected
ActiveLock(CompatibilitySpace space, Lockable ref, Object qualifier)

Initialize the lock, should be seen as part of the constructor.

Method Summary

Modifier and TypeMethod and Description
protected void
clearPotentiallyGranted()

Clear the potentially granted flag.

protected boolean
setPotentiallyGranted()

Set the potentially granted flag, returns true if the flag changed its state.

protected synchronized byte

Returns:

true if the wait ended early (ie. someone else woke us up).
waitForGrant
(int timeout)

Wait for a lock to be granted, returns when the lock is granted.

protected synchronized void
wakeUp(byte why)

Wake up anyone sleeping on this lock.

Inherited from org.apache.derby.impl.services.locks.Lock:
addWaiterscopyequalsfirstWaitergetCompatabilitySpacegetCountgetFirstGrantgetGrantedgetLockgetLockablegetLockControlgetQualifiergetWaitinggranthashCodeisEmptyisGrantableshallowCloneunlockunlock

Field Detail

canSkipback to summary
protected boolean canSkip

If 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.

potentiallyGrantedback to summary
pack-priv boolean potentiallyGranted

Set to true if the Lock potentially could be granted. MT - mutable - single thread required

wakeUpNowback to summary
pack-priv byte wakeUpNow

Set to true if the object waiting on this thread should wake up, MT - mutable - java synchronized(this)

Constructor Detail

ActiveLockback to summary
protected ActiveLock(CompatibilitySpace space, Lockable ref, Object qualifier)

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 Detail

clearPotentiallyGrantedback to summary
protected void clearPotentiallyGranted()

Clear the potentially granted flag. MT - single thread required

setPotentiallyGrantedback to summary
protected boolean setPotentiallyGranted()

Set the potentially granted flag, returns true if the flag changed its state. MT - single thread required

waitForGrantback to summary
protected synchronized byte waitForGrant(int timeout) throws StandardException

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:byte

true if the wait ended early (ie. someone else woke us up).

Exceptions
StandardException:
timeout, deadlock or thread interrupted
wakeUpback to summary
protected synchronized void wakeUp(byte why)

Wake up anyone sleeping on this lock. MT - Thread Safe