|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.support.lang.ObjectProxySupport<ReentrantLock>
org.entityfs.lock.impl.EntityLockReentrantLockAdapterImpl
public class EntityLockReentrantLockAdapterImpl
This is an adapter to let a ReentrantLock
implement the
EntityLock
interface. The adapter can be a read lock, a write lock or
a lock that is both.
Constructor Summary | |
---|---|
EntityLockReentrantLockAdapterImpl(boolean fair,
Lockable locked,
boolean readLock,
boolean writeLock)
Constructor. |
Method Summary | |
---|---|
int |
getHoldCount()
Get the hold count of the lock. |
Lockable |
getLocked()
Get the locked object. |
boolean |
isDummy()
Is this lock a dummy lock. |
boolean |
isHeldByCurrentThread()
Is this lock held by the current thread? (This is implemented by ReentrantLock but not specified in the Lock interface.) |
boolean |
isReadLock()
Returns true if this lock is a read lock. |
boolean |
isWriteLock()
Returns true if this lock is a write lock. |
void |
lock()
|
void |
lockInterruptibly()
|
Condition |
newCondition()
|
boolean |
tryLock()
|
boolean |
tryLock(long timeout,
TimeUnit unit)
|
void |
unlock()
|
Methods inherited from class org.entityfs.support.lang.ObjectProxySupport |
---|
equals, getProxied, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public EntityLockReentrantLockAdapterImpl(boolean fair, Lockable locked, boolean readLock, boolean writeLock)
fair
- Should fair queuing be used when acquiring locks?locked
- The locked object.readLock
- Is this a read lock for the entity?writeLock
- Is this a write lock for the entity?Method Detail |
---|
public Lockable getLocked()
EntityLock
null
.
getLocked
in interface EntityLock
null
if this lock is not connected
to any particular object.public boolean isReadLock()
EntityLock
true
if this lock is a read lock.
isReadLock
in interface EntityLock
true
if this is a read lock, false
if it is a
write lock.public boolean isWriteLock()
EntityLock
true
if this lock is a write lock.
isWriteLock
in interface EntityLock
true
if this is a write lock, false
if this is a
read lock.public void lock()
lock
in interface Lock
public Condition newCondition()
newCondition
in interface Lock
public void unlock()
unlock
in interface Lock
public boolean isHeldByCurrentThread()
EntityLock
ReentrantLock
but not specified in the Lock
interface.)
isHeldByCurrentThread
in interface EntityLock
true
if this lock is locked by the current thread.public boolean tryLock()
tryLock
in interface Lock
public boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
public int getHoldCount()
EntityLock
Lock.lock()
has been
called minus the number of times Lock.unlock()
has been called by
the current thread.) If the hold count is 0, the lock is unlocked. The
hold count can never be less than 0.
getHoldCount
in interface EntityLock
public void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
public boolean isDummy()
EntityLock
isDummy
in interface EntityLock
false
, always.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |