|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.catalina.tribes.transport.bio.util.SingleRemoveSynchronizedAddLock
public class SingleRemoveSynchronizedAddLock
The class SingleRemoveSynchronizedAddLock implement locking for accessing the queue by a single remove thread and multiple add threads. A thread is only allowed to be either the remove or an add thread. The lock can either be owned by the remove thread or by a single add thread. If the remove thread tries to get the lock, but the queue is empty, it will block (poll) until an add threads adds an entry to the queue and releases the lock. If the remove thread and add threads compete for the lock and an add thread releases the lock, then the remove thread will get the lock first. The remove thread removes all entries in the queue at once and proceeses them without further polling the queue. The lock is not reentrant, in the sense, that all threads must release an owned lock before competing for the lock again!
Constructor Summary | |
---|---|
SingleRemoveSynchronizedAddLock()
|
|
SingleRemoveSynchronizedAddLock(boolean dataAvailable)
|
Method Summary | |
---|---|
void |
abortRemove()
Abort any polling remover thread |
long |
getAddWaitTimeout()
|
long |
getRemoveWaitTimeout()
|
boolean |
isAddLocked()
Check if an add thread owns the lock. |
boolean |
isDataAvailable()
Check if the locked object has data available i.e. the remover can stop poling and get the lock. |
boolean |
isRemoveLocked()
Check if the remove thread owns the lock. |
boolean |
isRemovePolling()
Check if the remove thread is polling. |
void |
lockAdd()
Acquires the lock by an add thread and sets the add flag. |
boolean |
lockRemove()
Acquires the lock by the remove thread and sets the remove flag. |
void |
setAddWaitTimeout(long timeout)
Set value of addWaitTimeout |
void |
setRemoveWaitTimeout(long timeout)
Set value of removeWaitTimeout |
void |
unlockAdd(boolean dataAvailable)
Releases the lock by an add thread and reset the remove flag. |
void |
unlockRemove()
Releases the lock by the remove thread and reset the add flag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SingleRemoveSynchronizedAddLock()
public SingleRemoveSynchronizedAddLock(boolean dataAvailable)
Method Detail |
---|
public long getAddWaitTimeout()
public void setAddWaitTimeout(long timeout)
public long getRemoveWaitTimeout()
public void setRemoveWaitTimeout(long timeout)
public boolean isDataAvailable()
public boolean isAddLocked()
public boolean isRemoveLocked()
public boolean isRemovePolling()
public void lockAdd()
public boolean lockRemove()
public void unlockAdd(boolean dataAvailable)
public void unlockRemove()
public void abortRemove()
|
Apache Tomcat 6.0.53 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |