org.jboss.cache.util.concurrent.locks
Class ReentrantLockContainer<E>
java.lang.Object
org.jboss.cache.util.concurrent.locks.LockContainer<E>
org.jboss.cache.util.concurrent.locks.ReentrantLockContainer<E>
@ThreadSafe
public class ReentrantLockContainer<E>
- extends LockContainer<E>
A LockContainer that holds ReentrantLocks
- Since:
- 3.0
- Author:
- Manik Surtani (manik AT jboss DOT org)
- See Also:
OwnableReentrantLockContainer
Constructor Summary |
ReentrantLockContainer(int concurrencyLevel)
Creates a new LockContainer which uses a certain number of shared locks across all elements that need to be locked. |
ReentrantLockContainer
public ReentrantLockContainer(int concurrencyLevel)
- Creates a new LockContainer which uses a certain number of shared locks across all elements that need to be locked.
- Parameters:
concurrencyLevel
- concurrency level for number of stripes to create. Stripes are created in powers of two, with a minimum of concurrencyLevel created.
initLocks
protected void initLocks(int numLocks)
- Specified by:
initLocks
in class LockContainer<E>
getLock
public final ReentrantLock getLock(E object)
- Specified by:
getLock
in class LockContainer<E>
- Parameters:
object
- object
- Returns:
- the lock for a specific object
getNumLocksHeld
public final int getNumLocksHeld()
- Specified by:
getNumLocksHeld
in class LockContainer<E>
- Returns:
- number of locks held
ownsLock
public final boolean ownsLock(E object,
Object owner)
- Description copied from class:
LockContainer
- Tests if a give owner owns a lock on a specified object.
- Specified by:
ownsLock
in class LockContainer<E>
- Parameters:
object
- object to checkowner
- owner to test
- Returns:
- true if owner owns lock, false otherwise
isLocked
public final boolean isLocked(E object)
- Specified by:
isLocked
in class LockContainer<E>
- Parameters:
object
- object
- Returns:
- true if an object is locked, false otherwise
toString
public String toString()
- Overrides:
toString
in class Object
reset
public void reset()
- Description copied from class:
LockContainer
- Clears all locks held and re-initialises stripes.
- Specified by:
reset
in class LockContainer<E>
size
public int size()
- Specified by:
size
in class LockContainer<E>
Copyright © 2008 JBoss, a division of Red Hat. All Rights Reserved.