|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.messaging.utils.VariableLatch
public class VariableLatch
This class will use the framework provided to by AbstractQueuedSynchronizer.
AbstractQueuedSynchronizer is the framework for any sort of concurrent synchronization, such as Semaphores, events, etc, based on AtomicIntegers.
The idea is, instead of providing each user specific Latch/Synchronization, java.util.concurrent provides the framework for reuses, based on an AtomicInteger (getState())
On JBossMessaging we have the requirement of increment and decrement a counter until the user fires a ready event (commit). At that point we just act as a regular countDown.
Note: This latch is reusable. Once it reaches zero, you can call up again, and reuse it on further waits.
For example: prepareTransaction will wait for the current completions, and further adds will be called on the latch. Later on when commit is called you can reuse the same latch.
Constructor Summary | |
---|---|
VariableLatch()
|
Method Summary | |
---|---|
void |
down()
|
int |
getCount()
|
void |
up()
|
void |
waitCompletion()
|
boolean |
waitCompletion(long milliseconds)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public VariableLatch()
Method Detail |
---|
public int getCount()
public void up()
public void down()
public void waitCompletion() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean waitCompletion(long milliseconds) throws java.lang.InterruptedException
java.lang.InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |