net.wotonomy.foundation
Class NSMultiReaderLock

java.lang.Object
  extended by EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock
      extended by EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock
          extended by net.wotonomy.foundation.NSMultiReaderLock
All Implemented Interfaces:
EDU.oswego.cs.dl.util.concurrent.ReadWriteLock, NSLocking

public class NSMultiReaderLock
extends EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock
implements NSLocking

A Read-Write lock that allows unlimited number of calling threads to acquire read locks, but only one thread to acquire a write lock. It is also reentrant, allowing each thread to re-acquire it's lock recursively. For that reason it is somewhat slower, as there is a hash lookup when attempting to acquire and release reader locks. Of course a writer lock is quite a bit slower than a reader lock. A write lock is mutally exclusive with read locks, though a thread that has obtained a read-lock may be promoted to a write lock and vice versa when conditions permit.

Version:
$Revision: 893 $
Author:
cgruber@israfil.net, $Author: cgruber $

Nested Class Summary
 
Nested classes/interfaces inherited from class EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock
EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock.ReaderLock, EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock.Signaller, EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock.WriterLock
 
Field Summary
 
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock
IONE, readers_, writeHolds_
 
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock
activeReaders_, activeWriter_, readerLock_, waitingReaders_, waitingWriters_, writerLock_
 
Fields inherited from interface net.wotonomy.foundation.NSLocking
OneCentury, OneDay, OneHour, OneMinute, OneSecond, OneWeek, OneYear
 
Constructor Summary
NSMultiReaderLock()
           
 
Method Summary
protected  java.lang.String _padString(long l, int i)
           
protected  java.lang.String _padString(java.lang.String s, int i, boolean flag)
           
 void lock()
           
 void lockForReading()
           
 void lockForWriting()
           
 void retrieveReaderLocks()
           
 void suspendReaderLocks()
           
 java.lang.String toString()
           
 boolean tryLockForReading()
           
 boolean tryLockForWriting()
           
 void unlock()
           
 void unlockForReading()
           
 void unlockForWriting()
           
 
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock
allowReader, endRead, endWrite, startRead, startWrite
 
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock
cancelledWaitingReader, cancelledWaitingWriter, readLock, startReadFromNewReader, startReadFromWaitingReader, startWriteFromNewWriter, startWriteFromWaitingWriter, writeLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NSMultiReaderLock

public NSMultiReaderLock()
Method Detail

lockForReading

public void lockForReading()

unlockForReading

public void unlockForReading()

lock

public void lock()
Specified by:
lock in interface NSLocking

lockForWriting

public void lockForWriting()

unlock

public void unlock()
Specified by:
unlock in interface NSLocking

unlockForWriting

public void unlockForWriting()

suspendReaderLocks

public void suspendReaderLocks()
See Also:
com.webobjects.foundation.NSMultiReaderLock#suspendReaderLock()

retrieveReaderLocks

public void retrieveReaderLocks()
See Also:
com.webobjects.foundation.NSMultiReaderLock#retrieveReaderLock()

tryLockForWriting

public boolean tryLockForWriting()

tryLockForReading

public boolean tryLockForReading()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

_padString

protected java.lang.String _padString(long l,
                                      int i)

_padString

protected java.lang.String _padString(java.lang.String s,
                                      int i,
                                      boolean flag)


Copyright © 2006 null. All Rights Reserved.