org.codehaus.wadi.impl
Class RWLock
java.lang.Object
org.codehaus.wadi.impl.RWLock
- All Implemented Interfaces:
- ReadWriteLock
- Direct Known Subclasses:
- RankedRWLock
- public class RWLock
- extends Object
- implements ReadWriteLock
A read-write lock. Writers are preferred. Writers are ordered
according to 'priority'. A Reader may overlap release of its read
lock with its application for a write lock. A Writer may downgrade,
becoming a Reader.
- Version:
- $Revision: 1363 $
- Author:
- Jules Gosnell
Constructor Summary |
RWLock(int maxPriority)
|
_log
protected static final Log _log
_maxPriority
protected int _maxPriority
_priority
protected static ThreadLocal _priority
activeReaders_
protected long activeReaders_
activeWriter_
protected Thread activeWriter_
waitingReaders_
protected long waitingReaders_
waitingWriters_
protected long waitingWriters_
_listener
protected RWLockListener _listener
readerLock_
protected final RWLock.ReaderLock readerLock_
writerLock_
protected final RWLock.WriterLock writerLock_
RWLock
public RWLock(int maxPriority)
setPriority
public static void setPriority(int priority)
getPriority
public static int getPriority()
setListener
public void setListener(RWLockListener listener)
writeLock
public Sync writeLock()
- Specified by:
writeLock
in interface ReadWriteLock
readLock
public Sync readLock()
- Specified by:
readLock
in interface ReadWriteLock
cancelledWaitingReader
protected void cancelledWaitingReader()
cancelledWaitingWriter
protected void cancelledWaitingWriter(RWLock.Lock l)
allowReader
protected boolean allowReader()
startRead
protected boolean startRead()
startWrite
protected boolean startWrite()
startReadFromNewReader
protected boolean startReadFromNewReader()
startWriteFromNewWriter
protected boolean startWriteFromNewWriter(RWLock.Lock l)
startReadFromWaitingReader
protected boolean startReadFromWaitingReader()
startWriteFromWaitingWriter
protected boolean startWriteFromWaitingWriter(RWLock.Lock l)
notifyReadEnded
protected boolean notifyReadEnded()
endRead
protected RWLock.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 RWLock.Signaller endWrite()
- Called upon termination of a write.
Returns the object to signal to wake up a waiter, or null if no such
overlap
public void overlap()
throws InterruptedException
- Throws:
InterruptedException
downgrade
public void downgrade()
throws IllegalStateException
- Throws:
IllegalStateException
toString
public String toString()
Copyright © 2004-2008 Core Developers Network Ltd.. All Rights Reserved.