org.jboss.cache.lock
Class ReadWriteLockWithUpgrade

java.lang.Object
  extended by org.jboss.cache.lock.ReadWriteLockWithUpgrade
All Implemented Interfaces:
EDU.oswego.cs.dl.util.concurrent.ReadWriteLock
Direct Known Subclasses:
NonBlockingWriterLock

public class ReadWriteLockWithUpgrade
extends java.lang.Object
implements EDU.oswego.cs.dl.util.concurrent.ReadWriteLock


Nested Class Summary
protected  class ReadWriteLockWithUpgrade.ReaderLock
           
protected  class ReadWriteLockWithUpgrade.WriterLock
           
 
Field Summary
protected  java.lang.Thread activeWriter_
           
protected static java.lang.Object dummy_
           
protected static org.apache.commons.logging.Log log_
           
protected  ReadWriteLockWithUpgrade.ReaderLock readerLock_
           
protected static java.util.Map upgraderLocal_
           
protected  ReadWriteLockWithUpgrade.WriterLock writerLock_
           
 
Constructor Summary
ReadWriteLockWithUpgrade()
           
 
Method Summary
protected  boolean allowReader()
          Override this method to change to reader preference *
protected  void cancelledWaitingReader()
           
protected  void cancelledWaitingWriter()
           
protected  EDU.oswego.cs.dl.util.concurrent.Sync changeLock()
           
protected  org.jboss.cache.lock.ReadWriteLockWithUpgrade.Signaller endRead()
          Called upon termination of a read.
protected  org.jboss.cache.lock.ReadWriteLockWithUpgrade.Signaller endWrite()
          Called upon termination of a write.
 EDU.oswego.cs.dl.util.concurrent.Sync readLock()
           
protected  boolean startRead()
           
protected  boolean startReadFromNewReader()
           
protected  boolean startReadFromWaitingReader()
           
protected  boolean startWrite()
           
protected  boolean startWriteFromNewWriter()
           
protected  boolean startWriteFromWaitingWriter()
           
 java.lang.String toString()
           
 EDU.oswego.cs.dl.util.concurrent.Sync upgradeLockAttempt(long msecs)
          Attempt to obtain an upgrade to writer lock.
 EDU.oswego.cs.dl.util.concurrent.Sync writeLock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

activeWriter_

protected java.lang.Thread activeWriter_

upgraderLocal_

protected static final java.util.Map upgraderLocal_

dummy_

protected static final java.lang.Object dummy_

readerLock_

protected final ReadWriteLockWithUpgrade.ReaderLock readerLock_

writerLock_

protected final ReadWriteLockWithUpgrade.WriterLock writerLock_

log_

protected static final org.apache.commons.logging.Log log_
Constructor Detail

ReadWriteLockWithUpgrade

public ReadWriteLockWithUpgrade()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeLock

public EDU.oswego.cs.dl.util.concurrent.Sync writeLock()
Specified by:
writeLock in interface EDU.oswego.cs.dl.util.concurrent.ReadWriteLock

readLock

public EDU.oswego.cs.dl.util.concurrent.Sync readLock()
Specified by:
readLock in interface EDU.oswego.cs.dl.util.concurrent.ReadWriteLock

upgradeLockAttempt

public EDU.oswego.cs.dl.util.concurrent.Sync upgradeLockAttempt(long msecs)
                                                         throws UpgradeException
Attempt to obtain an upgrade to writer lock. If successful, the read lock is upgraded to write lock. If fails, the owner retains the read lock.

Parameters:
msecs - Time to wait in millisecons.
Returns:
Sync object. Null if not successful or timeout.
Throws:
UpgradeException

changeLock

protected EDU.oswego.cs.dl.util.concurrent.Sync changeLock()

cancelledWaitingReader

protected void cancelledWaitingReader()

cancelledWaitingWriter

protected void cancelledWaitingWriter()

allowReader

protected boolean allowReader()
Override this method to change to reader preference *


startRead

protected boolean startRead()

startWrite

protected boolean startWrite()

startReadFromNewReader

protected boolean startReadFromNewReader()

startWriteFromNewWriter

protected boolean startWriteFromNewWriter()

startReadFromWaitingReader

protected boolean startReadFromWaitingReader()

startWriteFromWaitingWriter

protected boolean startWriteFromWaitingWriter()

endRead

protected org.jboss.cache.lock.ReadWriteLockWithUpgrade.Signaller endRead()
Called upon termination of a read. Returns the object to signal to wake up a waiter, or null if no such


endWrite

protected org.jboss.cache.lock.ReadWriteLockWithUpgrade.Signaller endWrite()
Called upon termination of a write. Returns the object to signal to wake up a waiter, or null if no such



Copyright © 1998-2005 JBoss Inc . All Rights Reserved.