Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.ematgine.utils.concurrent
Class FIFOReadWriteLock  view FIFOReadWriteLock download FIFOReadWriteLock.java

java.lang.Object
  extended byorg.ematgine.utils.concurrent.FIFOReadWriteLock
All Implemented Interfaces:
ReadWriteLock

public class FIFOReadWriteLock
extends java.lang.Object
implements ReadWriteLock

This class implements a policy for reader/writer locks in which incoming readers and writers contend in generally fair manner for entry. When one reader enters, all others may enter. When the last reader exits a waiting writer may enter. This does not provide globally FIFO behavior since readers arriving after a writer may join other readers (in the style of a Reader's preference RW lock). But it does ensure FIFO ordering across writers, so earlier writers will write first, modulo the caveats discussed with FIFOSemaphore, which is used for queuing.

[ Introduction to this package. ]


Nested Class Summary
(package private)  class FIFOReadWriteLock.ReaderSync
           
 
Field Summary
protected  FIFOSemaphore active_
          FIFO queue of threads waiting for access Also serves as the Writer lock
protected  Sync readerSync_
          Control reader access to active semaphore
 
Constructor Summary
FIFOReadWriteLock()
           
 
Method Summary
 Sync readLock()
          get the readLock
 Sync writeLock()
          get the writeLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

active_

protected final FIFOSemaphore active_
FIFO queue of threads waiting for access Also serves as the Writer lock


readerSync_

protected final Sync readerSync_
Control reader access to active semaphore

Constructor Detail

FIFOReadWriteLock

public FIFOReadWriteLock()
Method Detail

writeLock

public Sync writeLock()
Description copied from interface: ReadWriteLock
get the writeLock

Specified by:
writeLock in interface ReadWriteLock

readLock

public Sync readLock()
Description copied from interface: ReadWriteLock
get the readLock

Specified by:
readLock in interface ReadWriteLock