org.aspectj.org.eclipse.jdt.internal.core.search.indexing
Class ReadWriteMonitor

java.lang.Object
  extended by org.aspectj.org.eclipse.jdt.internal.core.search.indexing.ReadWriteMonitor

public class ReadWriteMonitor
extends java.lang.Object

Monitor ensuring no more than one writer working concurrently. Multiple readers are allowed to perform simultaneously.


Constructor Summary
ReadWriteMonitor()
           
 
Method Summary
 void enterRead()
          Concurrent reading is allowed Blocking only when already writing.
 void enterWrite()
          Only one writer at a time is allowed to perform Blocking only when already writing or reading.
 void exitRead()
          Only notify waiting writer(s) if last reader
 boolean exitReadEnterWrite()
          Atomic exitRead/enterWrite: Allows to keep monitor in between exit read and next enter write.
 void exitWrite()
          When writing is over, all readers and possible writers are granted permission to restart concurrently
 void exitWriteEnterRead()
          Atomic exitWrite/enterRead: Allows to keep monitor in between exit write and next enter read.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadWriteMonitor

public ReadWriteMonitor()
Method Detail

enterRead

public void enterRead()
Concurrent reading is allowed Blocking only when already writing.


enterWrite

public void enterWrite()
Only one writer at a time is allowed to perform Blocking only when already writing or reading.


exitRead

public void exitRead()
Only notify waiting writer(s) if last reader


exitWrite

public void exitWrite()
When writing is over, all readers and possible writers are granted permission to restart concurrently


exitReadEnterWrite

public boolean exitReadEnterWrite()
Atomic exitRead/enterWrite: Allows to keep monitor in between exit read and next enter write. Use when writing changes is optional, otherwise call the individual methods. Returns false if multiple readers are accessing the index.


exitWriteEnterRead

public void exitWriteEnterRead()
Atomic exitWrite/enterRead: Allows to keep monitor in between exit write and next enter read. When writing is over, all readers are granted permissing to restart concurrently. This is the same as:
 synchronized(monitor) {
   monitor.exitWrite();
   monitor.enterRead();
 }
 


toString

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