@ThreadSafe public class ReentrantStripedLockContainer extends AbstractStripedLockContainer<ReentrantLock>
OwnableReentrantStripedLockContainer
Constructor and Description |
---|
ReentrantStripedLockContainer(int concurrencyLevel)
Creates a new LockContainer which uses a certain number of shared locks across all elements that need to be
locked.
|
Modifier and Type | Method and Description |
---|---|
ReentrantLock |
getLock(Object object) |
int |
getNumLocksHeld() |
protected void |
initLocks(int numLocks) |
boolean |
isLocked(Object object) |
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(ReentrantLock lock,
long timeout,
TimeUnit unit,
Object unused) |
protected void |
unlock(ReentrantLock l,
Object unused) |
acquireLock, getLockId, releaseLock
safeRelease
public ReentrantStripedLockContainer(int concurrencyLevel)
concurrencyLevel
- concurrency level for number of stripes to create. Stripes are created in powers of two,
with a minimum of concurrencyLevel created.protected void initLocks(int numLocks)
initLocks
in class AbstractStripedLockContainer<ReentrantLock>
public final ReentrantLock getLock(Object object)
object
- objectpublic final int getNumLocksHeld()
public int size()
public final boolean ownsLock(Object object, Object ignored)
LockContainer
object
- object to checkignored
- owner to testpublic final boolean isLocked(Object object)
object
- objectprotected void unlock(ReentrantLock l, Object unused)
unlock
in class AbstractLockContainer<ReentrantLock>
protected boolean tryLock(ReentrantLock lock, long timeout, TimeUnit unit, Object unused) throws InterruptedException
tryLock
in class AbstractLockContainer<ReentrantLock>
InterruptedException
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.