org.castor.util.concurrent
Class WriterPreferenceReadWriteLock
java.lang.Object
org.castor.util.concurrent.WriterPreferenceReadWriteLock
- ReadWriteLock
public class WriterPreferenceReadWriteLock
extends java.lang.Object
A ReadWriteLock that prefers waiting writers over waiting readers when there
is contention. This class is adapted from the versions described in CPJ,
improving on the ones there a bit by segregating reader and writer wait
queues, which is typically more efficient.
The locks are
NOT reentrant. In particular, even though it may
appear to usually work OK, a thread holding a read lock should not attempt to
re-acquire it. Doing so risks lockouts when there are also waiting writers.
[
Introduction to this package. ]
activeReaders_
protected long activeReaders_
activeWriter_
protected Thread activeWriter_
waitingReaders_
protected long waitingReaders_
waitingWriters_
protected long waitingWriters_
allowReader
protected boolean allowReader()
Override this method to change to reader preference *
cancelledWaitingReader
protected void cancelledWaitingReader()
cancelledWaitingWriter
protected void cancelledWaitingWriter()
startRead
protected boolean startRead()
startReadFromNewReader
protected boolean startReadFromNewReader()
startReadFromWaitingReader
protected boolean startReadFromWaitingReader()
startWrite
protected boolean startWrite()
startWriteFromNewWriter
protected boolean startWriteFromNewWriter()
startWriteFromWaitingWriter
protected boolean startWriteFromWaitingWriter()
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com