|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.entityfs.lock.CompoundEntityLock
public class CompoundEntityLock
This is an EntityLock
that contains a collection of
EntityLock
:s. When this lock is locked, all locks in the internal
list are locked, in the list iteration order.
The internal state of this object is protected by its intrinsic lock (synchronized
). This may lead to deadlocks between threads that try to lock
this lock if either of them holds any of the locks that this compound lock
contains.
Constructor Summary | |
---|---|
CompoundEntityLock(Collection<? extends EntityLock> c,
boolean writeLock)
Create a new compound lock instance. |
Method Summary | |
---|---|
int |
getHoldCount()
Get the hold count of the lock. |
EntityView |
getLocked()
Get the locked object. |
boolean |
isDummy()
Is this a dummy lock? This lock is a dummy lock if all its locks are. |
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()
Try to lock this lock. |
boolean |
tryLock(long timeout,
TimeUnit tu)
Try to lock this lock. |
void |
unlock()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompoundEntityLock(Collection<? extends EntityLock> c, boolean writeLock)
c
- The collection of locks. The locks are added to this object's
internal list of locks in the order that they are returned when iterating
over the collection.writeLock
- Is this a write lock (true
) or a read lock (
false
)?Method Detail |
---|
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 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 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 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 void unlock()
unlock
in interface Lock
public void lock()
lock
in interface Lock
public void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
public boolean tryLock(long timeout, TimeUnit tu) throws InterruptedException
tryLock
in interface Lock
InterruptedException
- If interrupted, all locks that have been
locked by this method before the interrupted are unlocked before throwing
the exception.public boolean tryLock()
tryLock
in interface Lock
public Condition newCondition()
newCondition
in interface Lock
Condition
created from the first lock in the lock list.
This may or may not be what clients want.public EntityView getLocked() throws UnsupportedOperationException
EntityLock
null
.
getLocked
in interface EntityLock
null
if this lock is not connected
to any particular object.
UnsupportedOperationException
- Always!public boolean isDummy()
isDummy
in interface EntityLock
true
if this lock is a dummy lock.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |