info.aduna.concurrent.locks
Class WritePrefReadWriteLockManager

java.lang.Object
  extended by info.aduna.concurrent.locks.WritePrefReadWriteLockManager
All Implemented Interfaces:
ReadWriteLockManager

public class WritePrefReadWriteLockManager
extends Object
implements ReadWriteLockManager

A read/write lock manager with writer preference. As soon as a write lock is requested, this lock manager will block any read lock requests until the writer's request has been satisfied.

Author:
Arjohn Kampman

Constructor Summary
WritePrefReadWriteLockManager()
          Creates a MultiReadSingleWriteLockManager.
WritePrefReadWriteLockManager(boolean trackLocks)
          Creates a new MultiReadSingleWriteLockManager, optionally with lock tracking enabled.
 
Method Summary
 Lock getReadLock()
          Gets a read lock.
 Lock getWriteLock()
          Gets an exclusive write lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WritePrefReadWriteLockManager

public WritePrefReadWriteLockManager()
Creates a MultiReadSingleWriteLockManager.


WritePrefReadWriteLockManager

public WritePrefReadWriteLockManager(boolean trackLocks)
Creates a new MultiReadSingleWriteLockManager, optionally with lock tracking enabled.

Parameters:
trackLocks - Controls whether the lock manager will keep track of active locks. Enabling lock tracking will add some overhead, but can be very useful for debugging.
Method Detail

getReadLock

public Lock getReadLock()
                 throws InterruptedException
Gets a read lock. This method blocks when a write lock is in use or has been requested until the write lock is released.

Specified by:
getReadLock in interface ReadWriteLockManager
Throws:
InterruptedException - In case the thread requesting the lock was interrupted.

getWriteLock

public Lock getWriteLock()
                  throws InterruptedException
Gets an exclusive write lock. This method blocks when the write lock is in use or has already been requested until the write lock is released. This method also block when read locks are active until all of them are released.

Specified by:
getWriteLock in interface ReadWriteLockManager
Throws:
InterruptedException - In case the thread requesting the lock was interrupted.


Copyright © 1997-2008 Aduna. All Rights Reserved.