edu.rice.cs.util
Class ReaderWriterLock.ReaderWriterThread

java.lang.Object
  extended by edu.rice.cs.util.ReaderWriterLock.ReaderWriterThread
Direct Known Subclasses:
ReaderWriterLock.Reader, ReaderWriterLock.Writer
Enclosing class:
ReaderWriterLock

public abstract class ReaderWriterLock.ReaderWriterThread
extends Object

Represents a thread waiting to either read or write. Instances of this class are placed in a queue to enforce the correct order when allowing new threads to read or write. The waiting thread must call wait() on this object, allowing it to be notified when it reaches the front of the queue. This object will remain on the queue until the thread completes its read or write, allowing us to check for and prevent deadlock if the same thread tries to both read and write at the same time.


Constructor Summary
ReaderWriterLock.ReaderWriterThread()
           
 
Method Summary
abstract  boolean isReader()
          Returns whether this ReaderWriter is a reader.
abstract  boolean isWriter()
          Returns whether this ReaderWriter is a writer.
 void startWaiting()
          Causes this ReaderWriterThread to wait until stopWaiting is called.
 void stopWaiting()
          Wakes up this ReaderWriterThread, removing it from the waitQueue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReaderWriterLock.ReaderWriterThread

public ReaderWriterLock.ReaderWriterThread()
Method Detail

isWriter

public abstract boolean isWriter()
Returns whether this ReaderWriter is a writer.


isReader

public abstract boolean isReader()
Returns whether this ReaderWriter is a reader.


startWaiting

public void startWaiting()
Causes this ReaderWriterThread to wait until stopWaiting is called. While it's waiting, it is on the waitQueue.


stopWaiting

public void stopWaiting()
Wakes up this ReaderWriterThread, removing it from the waitQueue.