org.jboss.cache.lock
Class ReadWriteLockWithUpgrade
java.lang.Object
org.jboss.cache.lock.ReadWriteLockWithUpgrade
- All Implemented Interfaces:
- ReadWriteLock
- Direct Known Subclasses:
- NonBlockingWriterLock
public class ReadWriteLockWithUpgrade
- extends Object
- implements ReadWriteLock
activeWriter_
protected Thread activeWriter_
upgraderLocal_
protected static final Map<ReadWriteLock,Object> upgraderLocal_
dummy_
protected static final Object dummy_
readerLock_
protected final ReadWriteLockWithUpgrade.ReaderLock readerLock_
writerLock_
protected final ReadWriteLockWithUpgrade.WriterLock writerLock_
log_
protected static final org.apache.commons.logging.Log log_
ReadWriteLockWithUpgrade
public ReadWriteLockWithUpgrade()
toString
public String toString()
- Overrides:
toString
in class Object
writeLock
public Lock writeLock()
- Specified by:
writeLock
in interface ReadWriteLock
readLock
public Lock readLock()
- Specified by:
readLock
in interface ReadWriteLock
upgradeLockAttempt
public Lock 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 Lock 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 © 2007 JBoss, a division of Red Hat. All Rights Reserved.