|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.exist.storage.lock.MultiReadReentrantLock
public class MultiReadReentrantLock
A reentrant read/write lock, which allows multiple readers to acquire a lock. Waiting writers are preferred.
This is an adapted and bug-fixed version of code taken from Apache's Turbine JCS.
Field Summary |
---|
Fields inherited from interface org.exist.storage.lock.Lock |
---|
NO_LOCK, READ_LOCK, WRITE_LOCK |
Constructor Summary | |
---|---|
MultiReadReentrantLock(Object id)
Default constructor. |
Method Summary | |
---|---|
boolean |
acquire()
Acquire a lock for read. |
boolean |
acquire(int mode)
Acquire a lock for read or write. |
boolean |
attempt(int mode)
Attempt to acquire a lock for read or write. |
String |
getId()
|
LockInfo |
getLockInfo()
Create a LockInfo entry for the given lock. |
Thread |
getWriteLockedThread()
|
boolean |
hasLock()
Check if the lock is currently locked by someone. |
boolean |
hasLock(Thread owner)
Check if the specified thread holds either a write or a read lock on the resource. |
boolean |
isLockedForRead(Thread owner)
Check if the specified thread does currently hold a read lock. |
boolean |
isLockedForWrite()
Returns true if there are active or pending write locks. |
void |
release()
|
void |
release(int mode)
Release a lock of the specified type. |
void |
release(int mode,
int count)
|
void |
wakeUp()
Wake up waiting threads and recompute dependencies. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultiReadReentrantLock(Object id)
Method Detail |
---|
public String getId()
getId
in interface Lock
public boolean acquire() throws LockException
Lock
acquire
in interface Lock
LockException
public boolean acquire(int mode) throws LockException
Lock
Lock.READ_LOCK
or
Lock.WRITE_LOCK
.
acquire
in interface Lock
LockException
public boolean attempt(int mode)
Lock
attempt
in interface Lock
public void release()
public void release(int mode)
Lock
release
in interface Lock
public void release(int mode, int count)
release
in interface Lock
public boolean isLockedForWrite()
Lock
isLockedForWrite
in interface Lock
public boolean hasLock()
Lock
hasLock
in interface Lock
public boolean isLockedForRead(Thread owner)
Lock
isLockedForRead
in interface Lock
owner
- the thread to search for
public Thread getWriteLockedThread()
public boolean hasLock(Thread owner)
hasLock
in interface Lock
owner
- the thread
public void wakeUp()
Lock
wakeUp
in interface Lock
public LockInfo getLockInfo()
Lock
getLockInfo
in interface Lock
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |