org.jboss.cache.lock
Class ReadWriteLockWithUpgrade

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

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


Nested Class Summary
protected  class ReadWriteLockWithUpgrade.ReaderLock
           
protected  class ReadWriteLockWithUpgrade.WriterLock
           
 
Field Summary
protected  Thread activeWriter_
           
protected static Object dummy_
           
protected static org.jboss.logging.Logger log_
           
protected  ReadWriteLockWithUpgrade.ReaderLock readerLock_
           
protected  ThreadLocal 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()
           
 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 Thread activeWriter_

upgraderLocal_

protected final ThreadLocal upgraderLocal_

dummy_

protected static final Object dummy_

readerLock_

protected final ReadWriteLockWithUpgrade.ReaderLock readerLock_

writerLock_

protected final ReadWriteLockWithUpgrade.WriterLock writerLock_

log_

protected static final org.jboss.logging.Logger log_
Constructor Detail

ReadWriteLockWithUpgrade

public ReadWriteLockWithUpgrade()
Method Detail

toString

public String toString()

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 © 2002 JBoss Group, LLC. All Rights Reserved.