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.
AbstractLatch.CountSync
control
Constructor and Description |
---|
ReusableLatch() |
ReusableLatch(int count) |
Modifier and Type | Method and Description |
---|---|
void |
countDown() |
void |
countDown(int count) |
public ReusableLatch()
public ReusableLatch(int count)
public void countDown()
countDown
in class AbstractLatch
public void countDown(int count)
countDown
in class AbstractLatch
Copyright © 2021 JBoss by Red Hat. All rights reserved.