Class ConditionLatch
- java.lang.Object
-
- de.aristaflow.adept2.util.locking.ConditionLatch
-
public class ConditionLatch extends Object
This is similar to a normalCountDownLatch
but it uses a wrapped lock for synchronising as well as a new corresponding condition for signalling. This allows to have a latch that releases a lock when waiting for the latch.
-
-
Constructor Summary
Constructors Constructor Description ConditionLatch(Lock lock)
Creates a new latch with the designated latch and a count of 1.ConditionLatch(Lock lock, long count)
Creates a new latch with the designated latch and the designated count.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
await()
boolean
await(long timeout, TimeUnit unit)
void
countDown()
long
getCount()
-
-
-
Constructor Detail
-
ConditionLatch
public ConditionLatch(Lock lock)
Creates a new latch with the designated latch and a count of 1.- Parameters:
lock
- The lock with which to synchronise access to this latch.
-
ConditionLatch
public ConditionLatch(Lock lock, long count)
Creates a new latch with the designated latch and the designated count.- Parameters:
lock
- The lock with which to synchronise access to this latch.count
- The number of releases before this latch releases threads.
-
-
Method Detail
-
await
public void await() throws InterruptedException
- Throws:
InterruptedException
- See Also:
CountDownLatch.await()
-
await
public boolean await(long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
- See Also:
CountDownLatch.await(long, TimeUnit)
-
countDown
public void countDown()
- See Also:
CountDownLatch.countDown()
-
getCount
public long getCount()
- See Also:
CountDownLatch.getCount()
-
-