![]() |
All Packages This Package Class Hierarchy Class Search Index Class calypso.util.RWLockjava.lang.Object | +----calypso.util.RWLock A "read-write" lock. This lock allows for an arbitrary number of simultaneous readers. The lock can be upgraded to a write lock in two ways. First, the lock can be upgraded without guaranteeing invariance across the transition (in other words, the read lock may need to be released before the write lock can be acquired). The other form of upgrade guarantees invariance; however, the upgrade can only be performed by initially locking the lock using the invariant read lock enter method. Upgrading the lock in either case involves waiting until there are no more readers. This implementation gives priority to upgrades and invariant locks which may lead to reader starvation. Each thread using the lock may re-enter the lock as many times as needed. However, attempting to re-enter the lock with the invariant read lock will fail unless the lock was originally entered that way by the invoking thread. Only one thread may enter the invariant read lock at a time; other threads attempting this will block until the owning thread exits the lock completely. Note that the implementation assumes that the user of instances of this class properly pairs the enters/exits.
public final class RWLock
extends java.lang.Object
{
// Fields 13
private LockState fFreeList;
private int fFreeListLength;
private int fInvariantLockCount;
private Thread fInvariantLockOwner;
private int fNumReaders;
private LockState fStateList;
private int fWriteLockCount;
private Thread fWriteLockOwner;
static final int kInvariantRead;
private static final int kMaxFreeListLength;
static final int kRead;
static String[] kStateToString;
static final int kWrite;
// Constructors 1
public RWLock();
// Methods 11
private void appendLockState(Thread, int);
public synchronized void enterInvariantReadLock() throws InterruptedException;
public synchronized void enterReadLock() throws InterruptedException;
public synchronized void enterWriteLock() throws InterruptedException;
public synchronized void exitInvariantReadLock();
public synchronized void exitReadLock();
public synchronized void exitWriteLock();
private void freeLockState(LockState);
private boolean isLocked(Thread, int);
private LockState newLockState();
private void removeLockState(Thread, int);
// Inner Classes 1
static class LockState
}
Fields fNumReadersprivate int fNumReaders fWriteLockOwnerprivate Thread fWriteLockOwner fWriteLockCountprivate int fWriteLockCount fInvariantLockOwnerprivate Thread fInvariantLockOwner fInvariantLockCountprivate int fInvariantLockCount kReadstatic final int kRead kWritestatic final int kWrite kInvariantReadstatic final int kInvariantRead kStateToStringstatic String[] kStateToString fStateListprivate LockState fStateList
fFreeListprivate LockState fFreeList
fFreeListLengthprivate int fFreeListLength kMaxFreeListLengthprivate static final int kMaxFreeListLength
Constructors RWLockpublic RWLock() Methods enterReadLockpublic synchronized void enterReadLock() throws InterruptedException exitReadLockpublic synchronized void exitReadLock() enterInvariantReadLockpublic synchronized void enterInvariantReadLock() throws InterruptedException
exitInvariantReadLockpublic synchronized void exitInvariantReadLock() enterWriteLockpublic synchronized void enterWriteLock() throws InterruptedException exitWriteLockpublic synchronized void exitWriteLock() isLockedprivate boolean isLocked(Thread aThread, int aHow)
appendLockStateprivate void appendLockState(Thread aThread, int aState) removeLockStateprivate void removeLockState(Thread aThread, int aState)
newLockStateprivate LockState newLockState() freeLockStateprivate void freeLockState(LockState aState) All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4 |
|||||||
| Copyright © 1998-1999 The Mozilla Organization. | |||||||