org.apache.derby.impl.services.locks
Class Lock

java.lang.Object
  extended byorg.apache.derby.impl.services.locks.Lock
All Implemented Interfaces:
Control, Latch
Direct Known Subclasses:
ActiveLock

public class Lock
extends java.lang.Object
implements Latch, Control

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


Field Summary
(package private)  int count
           
private  java.lang.Object qualifier
          Qualifier used in the lock request..
private  Lockable ref
          Object being locked.
private  java.lang.Object space
          Compatibility space the object is locked in.
 
Constructor Summary
protected Lock(java.lang.Object space, Lockable ref, java.lang.Object qualifier)
           
 
Method Summary
 void addWaiters(java.util.Dictionary waiters)
           
(package private)  Lock copy()
           
 boolean equals(java.lang.Object other)
           
 ActiveLock firstWaiter()
           
 java.lang.Object getCompatabilitySpace()
          Return the compatability space this lock is held in MT - Thread safe
 int getCount()
          Return the count of locks.
 Lock getFirstGrant()
           
 java.util.List getGranted()
           
 Lock getLock(java.lang.Object compatabilitySpace, java.lang.Object qualifier)
           
 Lockable getLockable()
          Return the object this lock is held on MT - Thread safe
 LockControl getLockControl()
           
 java.lang.Object getQualifier()
          Return the qualifier lock was obtained with.
 java.util.List getWaiting()
           
(package private)  void grant()
           
 int hashCode()
           
 boolean isEmpty()
           
 boolean isGrantable(boolean noWaitersBeforeMe, java.lang.Object compatabilitySpace, java.lang.Object requestQualifier)
           
 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.
(package private)  int unlock(int unlockCount)
           
 boolean unlock(Latch lockInGroup, int unlockCount)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

space

private final java.lang.Object 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(java.lang.Object 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:
getLockable in interface Latch

getCompatabilitySpace

public final java.lang.Object getCompatabilitySpace()
Return the compatability space this lock is held in MT - Thread safe

Specified by:
getCompatabilitySpace in interface Latch

getQualifier

public final java.lang.Object getQualifier()
Return the qualifier lock was obtained with. MT - Thread safe

Specified by:
getQualifier in interface Latch

getCount

public final int getCount()
Return the count of locks. MT - Thread safe

Specified by:
getCount in interface Latch

copy

final Lock copy()

grant

void grant()

unlock

int unlock(int unlockCount)

hashCode

public final int hashCode()

equals

public final boolean equals(java.lang.Object other)

getLockControl

public LockControl getLockControl()
Specified by:
getLockControl in interface Control

getLock

public Lock getLock(java.lang.Object compatabilitySpace,
                    java.lang.Object qualifier)
Specified by:
getLock in interface Control

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:
shallowClone in interface Control

firstWaiter

public ActiveLock firstWaiter()
Specified by:
firstWaiter in interface Control

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Control

unlock

public boolean unlock(Latch lockInGroup,
                      int unlockCount)
Specified by:
unlock in interface Control

addWaiters

public void addWaiters(java.util.Dictionary waiters)
Specified by:
addWaiters in interface Control

getFirstGrant

public Lock getFirstGrant()
Specified by:
getFirstGrant in interface Control

getGranted

public java.util.List getGranted()
Specified by:
getGranted in interface Control

getWaiting

public java.util.List getWaiting()
Specified by:
getWaiting in interface Control

isGrantable

public boolean isGrantable(boolean noWaitersBeforeMe,
                           java.lang.Object compatabilitySpace,
                           java.lang.Object requestQualifier)
Specified by:
isGrantable in interface Control

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.