Infinispan Distribution 5.2.6.Final-redhat-2

org.infinispan.util.concurrent.locks.containers
Class ReentrantStripedLockContainer

java.lang.Object
  extended by org.infinispan.util.concurrent.locks.containers.AbstractLockContainer<L>
      extended by org.infinispan.util.concurrent.locks.containers.AbstractStripedLockContainer<VisibleOwnerReentrantLock>
          extended by org.infinispan.util.concurrent.locks.containers.ReentrantStripedLockContainer
All Implemented Interfaces:
LockContainer<VisibleOwnerReentrantLock>

@ThreadSafe
public class ReentrantStripedLockContainer
extends AbstractStripedLockContainer<VisibleOwnerReentrantLock>

A LockContainer that holds ReentrantLocks

Since:
4.0
Author:
Manik Surtani (manik@jboss.org)
See Also:
OwnableReentrantStripedLockContainer

Constructor Summary
ReentrantStripedLockContainer(int concurrencyLevel)
          Creates a new LockContainer which uses a certain number of shared locks across all elements that need to be locked.
 
Method Summary
 VisibleOwnerReentrantLock getLock(Object object)
           
protected  Log getLog()
           
 int getNumLocksHeld()
           
protected  void initLocks(int numLocks)
           
 boolean isLocked(Object object)
           
protected  void lock(VisibleOwnerReentrantLock lock, Object lockOwner)
           
 boolean ownsLock(Object object, Object ignored)
          Tests if a give owner owns a lock on a specified object.
 int size()
           
 String toString()
           
protected  boolean tryLock(VisibleOwnerReentrantLock lock, long timeout, TimeUnit unit, Object unused)
           
protected  void unlock(VisibleOwnerReentrantLock l, Object unused)
           
 
Methods inherited from class org.infinispan.util.concurrent.locks.containers.AbstractStripedLockContainer
acquireLock, getLockId, releaseLock
 
Methods inherited from class org.infinispan.util.concurrent.locks.containers.AbstractLockContainer
safeRelease
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReentrantStripedLockContainer

public ReentrantStripedLockContainer(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.
Method Detail

getLog

protected Log getLog()
Specified by:
getLog in class AbstractLockContainer<VisibleOwnerReentrantLock>

initLocks

protected void initLocks(int numLocks)
Specified by:
initLocks in class AbstractStripedLockContainer<VisibleOwnerReentrantLock>

getLock

public final VisibleOwnerReentrantLock getLock(Object object)
Parameters:
object - object
Returns:
the lock for a specific object. May be null if the object is not locked, but may also be an unlocked lock.

getNumLocksHeld

public final int getNumLocksHeld()
Returns:
number of locks held

size

public int size()
Returns:
the size of the shared lock pool

ownsLock

public final boolean ownsLock(Object object,
                              Object ignored)
Description copied from interface: LockContainer
Tests if a give owner owns a lock on a specified object.

Parameters:
object - object to check
ignored - 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

toString

public String toString()
Overrides:
toString in class Object

unlock

protected void unlock(VisibleOwnerReentrantLock l,
                      Object unused)
Specified by:
unlock in class AbstractLockContainer<VisibleOwnerReentrantLock>

tryLock

protected boolean tryLock(VisibleOwnerReentrantLock lock,
                          long timeout,
                          TimeUnit unit,
                          Object unused)
                   throws InterruptedException
Specified by:
tryLock in class AbstractLockContainer<VisibleOwnerReentrantLock>
Throws:
InterruptedException

lock

protected void lock(VisibleOwnerReentrantLock lock,
                    Object lockOwner)
Specified by:
lock in class AbstractLockContainer<VisibleOwnerReentrantLock>

Infinispan Distribution 5.2.6.Final-redhat-2

Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.