org.apache.commons.transaction.locking
Class RWLockManager<K,M>

java.lang.Object
  extended by org.apache.commons.transaction.locking.AbstractLockManager<K,M>
      extended by org.apache.commons.transaction.locking.RWLockManager<K,M>
All Implemented Interfaces:
LockManager<K,M>

public class RWLockManager<K,M>
extends AbstractLockManager<K,M>
implements LockManager<K,M>

Advanced read/write lock implementation of a LockManager based on ResourceRWLock.

Note: This implementation performs deadlock detection.

This implementation is thread-safe.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.transaction.locking.AbstractLockManager
AbstractLockManager.KeyEntry<K,M>
 
Field Summary
protected  ConcurrentHashMap<AbstractLockManager.KeyEntry<K,M>,ResourceRWLock> allLocks
           
 
Fields inherited from class org.apache.commons.transaction.locking.AbstractLockManager
effectiveGlobalTimeouts, locksForThreads
 
Constructor Summary
RWLockManager()
           
 
Method Summary
protected  void cancelAllTimedOut()
           
protected  ResourceRWLock create(String name)
           
protected  void detectDeadlock(Thread thread, Set<Thread> path)
           
protected  boolean doTrickyYetEfficientLockOnlyIfThisCanNotCauseADeadlock(Lock lock, long timeMsecs)
           
 long getAbsolutePrewaitTime()
           
 long getPrewaitTimeDivisor()
           
protected  void release()
           
protected  void removeUnsuedLocks()
           
 void setAbsolutePrewaitTime(long absolutePrewaitTime)
           
 void setPrewaitTimeDivisor(long prewaitTimeDivisor)
           
protected  boolean tryLockInternal(M resourceManager, K key, boolean exclusive, long time, TimeUnit unit)
           
 
Methods inherited from class org.apache.commons.transaction.locking.AbstractLockManager
checkIsStarted, computeRemainingTime, endWork, hasTimedOut, isWorking, lock, reportTimeout, startWork, tryLock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.transaction.locking.LockManager
endWork, lock, startWork, tryLock
 

Field Detail

allLocks

protected ConcurrentHashMap<AbstractLockManager.KeyEntry<K,M>,ResourceRWLock> allLocks
Constructor Detail

RWLockManager

public RWLockManager()
Method Detail

release

protected void release()
Specified by:
release in class AbstractLockManager<K,M>

removeUnsuedLocks

protected void removeUnsuedLocks()

create

protected ResourceRWLock create(String name)

tryLockInternal

protected boolean tryLockInternal(M resourceManager,
                                  K key,
                                  boolean exclusive,
                                  long time,
                                  TimeUnit unit)
                           throws LockException
Specified by:
tryLockInternal in class AbstractLockManager<K,M>
Throws:
LockException

doTrickyYetEfficientLockOnlyIfThisCanNotCauseADeadlock

protected boolean doTrickyYetEfficientLockOnlyIfThisCanNotCauseADeadlock(Lock lock,
                                                                         long timeMsecs)
                                                                  throws LockException
Throws:
LockException

detectDeadlock

protected void detectDeadlock(Thread thread,
                              Set<Thread> path)

cancelAllTimedOut

protected void cancelAllTimedOut()

getAbsolutePrewaitTime

public long getAbsolutePrewaitTime()

setAbsolutePrewaitTime

public void setAbsolutePrewaitTime(long absolutePrewaitTime)

getPrewaitTimeDivisor

public long getPrewaitTimeDivisor()

setPrewaitTimeDivisor

public void setPrewaitTimeDivisor(long prewaitTimeDivisor)


Copyright © 2004-2007 The Apache Software Foundation. All Rights Reserved.