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

java.lang.Object
  extended by org.infinispan.util.concurrent.locks.containers.AbstractPerEntryLockContainer
All Implemented Interfaces:
LockContainer
Direct Known Subclasses:
OwnableReentrantPerEntryLockContainer, ReentrantPerEntryLockContainer

public abstract class AbstractPerEntryLockContainer
extends Object
implements LockContainer

An abstract lock container that creates and maintains a new lock per entry

Since:
4.0
Author:
Manik Surtani

Field Summary
protected  ConcurrentMap<Object,Lock> locks
           
 
Constructor Summary
protected AbstractPerEntryLockContainer(int concurrencyLevel)
           
 
Method Summary
 boolean acquireLock(Object key, long timeout, TimeUnit unit)
           
 Lock getLock(Object key)
           
 int getNumLocksHeld()
           
protected abstract  Lock newLock()
           
 void releaseLock(Object key)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.infinispan.util.concurrent.locks.containers.LockContainer
isLocked, ownsLock
 

Field Detail

locks

protected final ConcurrentMap<Object,Lock> locks
Constructor Detail

AbstractPerEntryLockContainer

protected AbstractPerEntryLockContainer(int concurrencyLevel)
Method Detail

newLock

protected abstract Lock newLock()

getLock

public final Lock getLock(Object key)
Specified by:
getLock in interface LockContainer
Parameters:
key - object
Returns:
the lock for a specific object

getNumLocksHeld

public int getNumLocksHeld()
Specified by:
getNumLocksHeld in interface LockContainer
Returns:
number of locks held

size

public int size()
Specified by:
size in interface LockContainer
Returns:
the size of the shared lock pool

acquireLock

public boolean acquireLock(Object key,
                           long timeout,
                           TimeUnit unit)
                    throws InterruptedException
Specified by:
acquireLock in interface LockContainer
Throws:
InterruptedException

releaseLock

public void releaseLock(Object key)
Specified by:
releaseLock in interface LockContainer

Google Analytics

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