Class ReusableLatch
- java.lang.Object
-
- org.apache.activemq.artemis.utils.AbstractLatch
-
- org.apache.activemq.artemis.utils.ReusableLatch
-
public class ReusableLatch extends AbstractLatch
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.
This class works just like CountDownLatch, with the difference you can also increase the counter
It could be used for sync points when one process is feeding the latch while another will wait when everything is done. (e.g. waiting IO completions to finish)
On ActiveMQ Artemis 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.activemq.artemis.utils.AbstractLatch
AbstractLatch.CountSync
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.artemis.utils.AbstractLatch
control
-
-
Constructor Summary
Constructors Constructor Description ReusableLatch()ReusableLatch(int count)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcountDown()voidcountDown(int count)
-
-
-
Method Detail
-
countDown
public void countDown()
- Specified by:
countDownin classAbstractLatch
-
countDown
public void countDown(int count)
- Specified by:
countDownin classAbstractLatch
-
-