org.logicalcobwebs.concurrent
类 WriterPreferenceReadWriteLock

java.lang.Object
  继承者 org.logicalcobwebs.concurrent.WriterPreferenceReadWriteLock
所有已实现的接口:
ReadWriteLock
直接已知子类:
ReaderPreferenceReadWriteLock

public class WriterPreferenceReadWriteLock
extends Object
implements ReadWriteLock

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. ]


嵌套类摘要
protected  class WriterPreferenceReadWriteLock.ReaderLock
           
protected  class WriterPreferenceReadWriteLock.Signaller
          Reader and Writer requests are maintained in two different wait sets, by two different objects.
protected  class WriterPreferenceReadWriteLock.WriterLock
           
 
字段摘要
protected  long activeReaders_
           
protected  Thread activeWriter_
           
protected  WriterPreferenceReadWriteLock.ReaderLock readerLock_
           
protected  long waitingReaders_
           
protected  long waitingWriters_
           
protected  WriterPreferenceReadWriteLock.WriterLock writerLock_
           
 
构造方法摘要
WriterPreferenceReadWriteLock()
           
 
方法摘要
protected  boolean allowReader()
          Override this method to change to reader preference
protected  void cancelledWaitingReader()
           
protected  void cancelledWaitingWriter()
           
protected  WriterPreferenceReadWriteLock.Signaller endRead()
          Called upon termination of a read.
protected  WriterPreferenceReadWriteLock.Signaller endWrite()
          Called upon termination of a write.
 Sync readLock()
          get the readLock
protected  boolean startRead()
           
protected  boolean startReadFromNewReader()
           
protected  boolean startReadFromWaitingReader()
           
protected  boolean startWrite()
           
protected  boolean startWriteFromNewWriter()
           
protected  boolean startWriteFromWaitingWriter()
           
 Sync writeLock()
          get the writeLock
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

activeReaders_

protected long activeReaders_

activeWriter_

protected Thread activeWriter_

waitingReaders_

protected long waitingReaders_

waitingWriters_

protected long waitingWriters_

readerLock_

protected final WriterPreferenceReadWriteLock.ReaderLock readerLock_

writerLock_

protected final WriterPreferenceReadWriteLock.WriterLock writerLock_
构造方法详细信息

WriterPreferenceReadWriteLock

public WriterPreferenceReadWriteLock()
方法详细信息

writeLock

public Sync writeLock()
从接口 ReadWriteLock 复制的描述
get the writeLock

指定者:
接口 ReadWriteLock 中的 writeLock

readLock

public Sync readLock()
从接口 ReadWriteLock 复制的描述
get the readLock

指定者:
接口 ReadWriteLock 中的 readLock

cancelledWaitingReader

protected void cancelledWaitingReader()

cancelledWaitingWriter

protected void cancelledWaitingWriter()

allowReader

protected boolean allowReader()
Override this method to change to reader preference


startRead

protected boolean startRead()

startWrite

protected boolean startWrite()

startReadFromNewReader

protected boolean startReadFromNewReader()

startWriteFromNewWriter

protected boolean startWriteFromNewWriter()

startReadFromWaitingReader

protected boolean startReadFromWaitingReader()

startWriteFromWaitingWriter

protected boolean startWriteFromWaitingWriter()

endRead

protected WriterPreferenceReadWriteLock.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 WriterPreferenceReadWriteLock.Signaller endWrite()
Called upon termination of a write. Returns the object to signal to wake up a waiter, or null if no such



Copyright © 2014. All rights reserved.