java.lang.Object
org.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. ]
|
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 |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
FIFOReadWriteLock
public FIFOReadWriteLock()
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