Class AwaitUtils
java.lang.Object
io.servicetalk.concurrent.test.internal.AwaitUtils
Utilities to do blocking await calls for tests.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
await
(CountDownLatch latch) Await aCountDownLatch
until the latch is counted down, throws unchecked InterruptedException.static boolean
await
(CountDownLatch latch, long timeout, TimeUnit unit) Await aCountDownLatch
until the latch is counted down or the given time duration expires, throws unchecked InterruptedException.static <T> T
poll
(BlockingQueue<T> queue, long timeout, TimeUnit unit) BlockingQueue.poll(long, TimeUnit)
from the queue, throws unchecked Exception if thread is interrupted while waiting.static <T> T
take
(BlockingQueue<T> queue) BlockingQueue.take()
from the queue or throws unchecked exception in the case of InterruptedException.
-
Method Details
-
await
Await aCountDownLatch
until the latch is counted down, throws unchecked InterruptedException.- Parameters:
latch
- theCountDownLatch
to await.
-
await
Await aCountDownLatch
until the latch is counted down or the given time duration expires, throws unchecked InterruptedException.- Parameters:
latch
- theCountDownLatch
to await.timeout
- the timeout duration to await for.unit
- the units applied totimeout
.- Returns:
- true if the count reached zero and false if the waiting time elapsed before the count reached zero
-
take
BlockingQueue.take()
from the queue or throws unchecked exception in the case of InterruptedException.- Type Parameters:
T
- The types of objects in the queue.- Parameters:
queue
- The queue to take from.- Returns:
- see
BlockingQueue.take()
.
-
poll
BlockingQueue.poll(long, TimeUnit)
from the queue, throws unchecked Exception if thread is interrupted while waiting.- Type Parameters:
T
- The types of objects in the queue.- Parameters:
queue
- the queue to poll from.timeout
- the timeout duration to poll for.unit
- the units applied totimeout
.- Returns:
- see
BlockingQueue.poll(long, TimeUnit)
.
-