org.infinispan.util.concurrent.locks.containers
Class OwnableReentrantStripedLockContainer
java.lang.Object
org.infinispan.util.concurrent.locks.containers.AbstractLockContainer<L>
org.infinispan.util.concurrent.locks.containers.AbstractStripedLockContainer<OwnableReentrantLock>
org.infinispan.util.concurrent.locks.containers.OwnableReentrantStripedLockContainer
- All Implemented Interfaces:
- LockContainer<OwnableReentrantLock>
@ThreadSafe
public class OwnableReentrantStripedLockContainer
- extends AbstractStripedLockContainer<OwnableReentrantLock>
A LockContainer that holds OwnableReentrantLock
s.
- Since:
- 4.0
- Author:
- Manik Surtani (manik@jboss.org)
- See Also:
ReentrantStripedLockContainer
,
OwnableReentrantLock
Constructor Summary |
OwnableReentrantStripedLockContainer(int concurrencyLevel)
Creates a new LockContainer which uses a certain number of shared locks across all elements that need to be
locked. |
OwnableReentrantStripedLockContainer
public OwnableReentrantStripedLockContainer(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 AbstractStripedLockContainer<OwnableReentrantLock>
getLock
public final OwnableReentrantLock getLock(Object object)
- Parameters:
object
- object
- Returns:
- the lock for a specific object
ownsLock
public final boolean ownsLock(Object 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(Object 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
size
public int size()
- Returns:
- the size of the shared lock pool
tryLock
protected boolean tryLock(OwnableReentrantLock lock,
long timeout,
TimeUnit unit,
Object lockOwner)
throws InterruptedException
- Specified by:
tryLock
in class AbstractLockContainer<OwnableReentrantLock>
- Throws:
InterruptedException
unlock
protected void unlock(OwnableReentrantLock l,
Object owner)
- Specified by:
unlock
in class AbstractLockContainer<OwnableReentrantLock>
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.