org.jboss.cache.util.concurrent.locks
Class OwnableReentrantSharedLockContainer<E>
java.lang.Object
org.jboss.cache.util.concurrent.locks.AbstractSharedLockContainer<E>
org.jboss.cache.util.concurrent.locks.OwnableReentrantSharedLockContainer<E>
- All Implemented Interfaces:
- LockContainer<E>
@ThreadSafe
public class OwnableReentrantSharedLockContainer<E>
- extends AbstractSharedLockContainer<E>
A LockContainer that holds OwnableReentrantLock
s.
- Since:
- 3.0
- Author:
- Manik Surtani (manik AT jboss DOT org)
- See Also:
ReentrantSharedLockContainer
,
OwnableReentrantLock
OwnableReentrantSharedLockContainer
public OwnableReentrantSharedLockContainer(int concurrencyLevel,
InvocationContextContainer icc)
- 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.icc
- invocation context container to use
initLocks
protected void initLocks(int numLocks)
- Specified by:
initLocks
in class AbstractSharedLockContainer<E>
getLock
public final OwnableReentrantLock getLock(E object)
- Parameters:
object
- object
- Returns:
- the lock for a specific object
ownsLock
public final boolean ownsLock(E object,
Object owner)
- Description copied from interface:
LockContainer
- Tests if a give owner owns a lock on a specified object.
- Parameters:
object
- object to checkowner
- owner to test
- Returns:
- true if owner owns lock, false otherwise
isLocked
public final boolean isLocked(E object)
- Parameters:
object
- object
- Returns:
- true if an object is locked, false otherwise
getNumLocksHeld
public final int getNumLocksHeld()
- Returns:
- number of locks held
toString
public String toString()
- Overrides:
toString
in class Object
reset
public void reset()
- Description copied from interface:
LockContainer
- Clears all locks held and re-initialises stripes.
size
public int size()
Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.