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

pack-priv Class Lock

extends Object
implements Latch, Control
Class Inheritance
All Implemented Interfaces
org.apache.derby.impl.services.locks.Control, org.apache.derby.iapi.services.locks.Latch
Known Direct Subclasses
org.apache.derby.impl.services.locks.ActiveLock
Imports
org.apache.derby.iapi.services.locks.CompatibilitySpace, .Lockable, .Latch, org.apache.derby.shared.common.sanity.SanityManager, java.util.List, .Map

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

Field Summary

Modifier and TypeField and Description
pack-priv int
private final Object
qualifier

Qualifier used in the lock request..

private final Lockable
ref

Object being locked.

private final CompatibilitySpace
space

Compatibility space the object is locked in. MT - immutable - reference only

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public void
pack-priv final Lock
copy()

public final boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public ActiveLock
public final CompatibilitySpace
getCompatabilitySpace()

Implements org.apache.derby.iapi.services.locks.Latch.getCompatabilitySpace.

Return the compatibility space this lock is held in. MT - Thread safe

public final int
getCount()

Implements org.apache.derby.iapi.services.locks.Latch.getCount.

Return the count of locks.

public Lock
public List<E>
public Lock
public final Lockable
public LockControl
public final Object
getQualifier()

Implements org.apache.derby.iapi.services.locks.Latch.getQualifier.

Return the qualifier lock was obtained with.

public List<E>
pack-priv void
public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public boolean
isGrantable(boolean noWaitersBeforeMe, CompatibilitySpace compatibilitySpace, Object requestQualifier)

Implements org.apache.derby.impl.services.locks.Control.isGrantable.

public Control
shallowClone()

Implements org.apache.derby.impl.services.locks.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.

pack-priv int
unlock(int unlockCount)

public boolean
unlock(Latch lockInGroup, int unlockCount)

Implements org.apache.derby.impl.services.locks.Control.unlock.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
pack-priv int count
qualifierback to summary
private final Object qualifier

Qualifier used in the lock request.. MT - immutable - reference only

refback to summary
private final Lockable ref

Object being locked. MT - immutable - reference only

spaceback to summary
private final CompatibilitySpace space

Compatibility space the object is locked in. MT - immutable - reference only

Constructor Detail

Lockback to summary
protected Lock(CompatibilitySpace space, Lockable ref, Object qualifier)

Method Detail

addWaitersback to summary
public void addWaiters(Map<K, V> waiters)

Implements org.apache.derby.impl.services.locks.Control.addWaiters.

copyback to summary
pack-priv final Lock copy()
equalsback to summary
public final boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

firstWaiterback to summary
public ActiveLock firstWaiter()

Implements org.apache.derby.impl.services.locks.Control.firstWaiter.

getCompatabilitySpaceback to summary
public final CompatibilitySpace getCompatabilitySpace()

Implements org.apache.derby.iapi.services.locks.Latch.getCompatabilitySpace.

Return the compatibility space this lock is held in. MT - Thread safe

Returns:CompatibilitySpace

Doc from org.apache.derby.iapi.services.locks.Latch.getCompatabilitySpace.

the latch's compatibility space

getCountback to summary
public final int getCount()

Implements org.apache.derby.iapi.services.locks.Latch.getCount.

Return the count of locks. MT - Thread safe

getFirstGrantback to summary
public Lock getFirstGrant()

Implements org.apache.derby.impl.services.locks.Control.getFirstGrant.

getGrantedback to summary
public List<E> getGranted()

Implements org.apache.derby.impl.services.locks.Control.getGranted.

getLockback to summary
public Lock getLock(CompatibilitySpace compatibilitySpace, Object qualifier)

Implements org.apache.derby.impl.services.locks.Control.getLock.

getLockableback to summary
public final Lockable getLockable()

Implements org.apache.derby.iapi.services.locks.Latch.getLockable, org.apache.derby.impl.services.locks.Control.getLockable.

Return the object this lock is held on MT - Thread safe

Returns:Lockable

Doc from org.apache.derby.iapi.services.locks.Latch.getLockable.

the object the latch is held on

getLockControlback to summary
public LockControl getLockControl()

Implements org.apache.derby.impl.services.locks.Control.getLockControl.

getQualifierback to summary
public final Object getQualifier()

Implements org.apache.derby.iapi.services.locks.Latch.getQualifier.

Return the qualifier lock was obtained with. MT - Thread safe

Returns:Object

Doc from org.apache.derby.iapi.services.locks.Latch.getQualifier.

the qualifier used when the latch was obtained

getWaitingback to summary
public List<E> getWaiting()

Implements org.apache.derby.impl.services.locks.Control.getWaiting.

grantback to summary
pack-priv void grant()
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

isEmptyback to summary
public boolean isEmpty()

Implements org.apache.derby.impl.services.locks.Control.isEmpty.

isGrantableback to summary
public boolean isGrantable(boolean noWaitersBeforeMe, CompatibilitySpace compatibilitySpace, Object requestQualifier)

Implements org.apache.derby.impl.services.locks.Control.isGrantable.

shallowCloneback to summary
public Control shallowClone()

Implements org.apache.derby.impl.services.locks.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.

unlockback to summary
pack-priv int unlock(int unlockCount)
unlockback to summary
public boolean unlock(Latch lockInGroup, int unlockCount)

Implements org.apache.derby.impl.services.locks.Control.unlock.