Class AwaitUtils
java.lang.Object
io.servicetalk.concurrent.test.internal.AwaitUtils
Utilities to do blocking await calls for tests.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidawait(CountDownLatch latch) Await aCountDownLatchuntil the latch is counted down, throws unchecked InterruptedException.static booleanawait(CountDownLatch latch, long timeout, TimeUnit unit) Await aCountDownLatchuntil the latch is counted down or the given time duration expires, throws unchecked InterruptedException.static <T> Tpoll(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> Ttake(BlockingQueue<T> queue) BlockingQueue.take()from the queue or throws unchecked exception in the case of InterruptedException.
-
Method Details
-
await
Await aCountDownLatchuntil the latch is counted down, throws unchecked InterruptedException.- Parameters:
latch- theCountDownLatchto await.
-
await
Await aCountDownLatchuntil the latch is counted down or the given time duration expires, throws unchecked InterruptedException.- Parameters:
latch- theCountDownLatchto 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).
-