org.jboss.cache.lock
Class ReadWriteLockWithUpgrade

java.lang.Object
  extended byorg.jboss.cache.lock.ReadWriteLockWithUpgrade
Direct Known Subclasses:
NonBlockingWriterLock (src)

public class ReadWriteLockWithUpgrade
extends java.lang.Object


Nested Class Summary
protected  class ReadWriteLockWithUpgrade.ReaderLock (src)
           
protected  class ReadWriteLockWithUpgrade.WriterLock (src)
           
 
Field Summary
protected  java.lang.Thread activeWriter_
           
protected static java.lang.Object dummy_
           
protected static Logger (src) log_
           
protected  ReadWriteLockWithUpgrade.ReaderLock (src) readerLock_
           
protected  java.lang.ThreadLocal upgraderLocal_
           
protected  ReadWriteLockWithUpgrade.WriterLock (src) writerLock_
           
 
Constructor Summary
ReadWriteLockWithUpgrade()
           
 
Method Summary
protected  boolean allowReader()
          Override this method to change to reader preference *
protected  void cancelledWaitingReader()
           
protected  void cancelledWaitingWriter()
           
protected  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.
 Sync readLock()
           
protected  boolean startRead()
           
protected  boolean startReadFromNewReader()
           
protected  boolean startReadFromWaitingReader()
           
protected  boolean startWrite()
           
protected  boolean startWriteFromNewWriter()
           
protected  boolean startWriteFromWaitingWriter()
           
 java.lang.String toString()
           
 Sync upgradeLockAttempt(long msecs)
          Attempt to obtain an upgrade to writer lock.
 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 final java.lang.ThreadLocal upgraderLocal_

dummy_

protected static final java.lang.Object dummy_

readerLock_

protected final ReadWriteLockWithUpgrade.ReaderLock (src)  readerLock_

writerLock_

protected final ReadWriteLockWithUpgrade.WriterLock (src)  writerLock_

log_

protected static final Logger (src)  log_
Constructor Detail

ReadWriteLockWithUpgrade

public ReadWriteLockWithUpgrade()
Method Detail

toString

public java.lang.String toString()

writeLock

public Sync writeLock()

readLock

public Sync readLock()

upgradeLockAttempt

public Sync upgradeLockAttempt(long msecs)
                        throws UpgradeException (src) 
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 (src)

changeLock

protected 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