public class ConditionLatch
extends java.lang.Object
CountDownLatch 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.| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.locks.Condition |
cond
The condition on which to wait for the latch.
|
protected long |
count
The number of releases before this latch releases threads.
|
protected java.util.concurrent.locks.Lock |
lock
The lock which to use for synchronising.
|
| Constructor and Description |
|---|
ConditionLatch(java.util.concurrent.locks.Lock lock)
Creates a new latch with the designated latch and a count of 1.
|
ConditionLatch(java.util.concurrent.locks.Lock lock,
long count)
Creates a new latch with the designated latch and the designated count.
|
| Modifier and Type | Method and Description |
|---|---|
void |
await() |
boolean |
await(long timeout,
java.util.concurrent.TimeUnit unit) |
void |
countDown() |
long |
getCount() |
protected final java.util.concurrent.locks.Lock lock
protected final java.util.concurrent.locks.Condition cond
protected long count
public ConditionLatch(java.util.concurrent.locks.Lock lock)
lock - The lock with which to synchronise access to this latch.public ConditionLatch(java.util.concurrent.locks.Lock lock,
long count)
lock - The lock with which to synchronise access to this latch.count - The number of releases before this latch releases threads.public void await()
throws java.lang.InterruptedException
java.lang.InterruptedExceptionCountDownLatch.await()public boolean await(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
java.lang.InterruptedExceptionCountDownLatch.await(long, TimeUnit)public void countDown()
CountDownLatch.countDown()public long getCount()
CountDownLatch.getCount()