org.jboss.cache.util.concurrent.locks
Class PerElementLockContainer<E>
java.lang.Object
org.jboss.cache.util.concurrent.locks.PerElementLockContainer<E>
- All Implemented Interfaces:
- LockContainer<E>
- Direct Known Subclasses:
- PerElementOwnableReentrantLockContainer, PerElementReentrantLockContainer
public abstract class PerElementLockContainer<E>
- extends Object
- implements LockContainer<E>
A lock container that maintains a new lock per element
- Since:
- 3.1.0
- Author:
- Manik Surtani
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
locks
protected final ConcurrentMap<E,Lock> locks
PerElementLockContainer
protected PerElementLockContainer(int concurrencyLevel)
newLock
protected abstract Lock newLock()
getLock
public final Lock getLock(E object)
- Specified by:
getLock
in interface LockContainer<E>
- Parameters:
object
- object
- Returns:
- the lock for a specific object
getNumLocksHeld
public int getNumLocksHeld()
- Specified by:
getNumLocksHeld
in interface LockContainer<E>
- Returns:
- number of locks held
reset
public void reset()
- Description copied from interface:
LockContainer
- Clears all locks held and re-initialises stripes.
- Specified by:
reset
in interface LockContainer<E>
size
public int size()
- Specified by:
size
in interface LockContainer<E>
acquireLock
public void acquireLock(E object)
- Specified by:
acquireLock
in interface LockContainer<E>
acquireLock
public boolean acquireLock(E object,
long timeout,
TimeUnit unit)
throws InterruptedException
- Specified by:
acquireLock
in interface LockContainer<E>
- Throws:
InterruptedException
releaseLock
public void releaseLock(E object)
- Specified by:
releaseLock
in interface LockContainer<E>
Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.