Class ReusableLatch
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 -
Method Summary
-
Constructor Details
-
ReusableLatch
public ReusableLatch() -
ReusableLatch
public ReusableLatch(int count)
-
-
Method Details
-
countDown
public void countDown()- Specified by:
countDownin classAbstractLatch
-
countDown
public void countDown(int count) - Specified by:
countDownin classAbstractLatch
-