@Beta public final class Uninterruptibles extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
awaitUninterruptibly(java.util.concurrent.CountDownLatch latch)
Invokes
latch. await()
uninterruptibly. |
static boolean |
awaitUninterruptibly(java.util.concurrent.CountDownLatch latch,
long timeout,
java.util.concurrent.TimeUnit unit)
Invokes
latch. await(timeout, unit) uninterruptibly. |
static <V> V |
getUninterruptibly(java.util.concurrent.Future<V> future)
Invokes
future. get() uninterruptibly. |
static <V> V |
getUninterruptibly(java.util.concurrent.Future<V> future,
long timeout,
java.util.concurrent.TimeUnit unit)
Invokes
future. get(timeout, unit)
uninterruptibly. |
static void |
joinUninterruptibly(java.lang.Thread toJoin)
Invokes
toJoin. join() uninterruptibly. |
static void |
joinUninterruptibly(java.lang.Thread toJoin,
long timeout,
java.util.concurrent.TimeUnit unit)
Invokes
unit. timedJoin(toJoin, timeout) uninterruptibly. |
static <E> void |
putUninterruptibly(java.util.concurrent.BlockingQueue<E> queue,
E element)
Invokes
queue. put(element)
uninterruptibly. |
static void |
sleepUninterruptibly(long sleepFor,
java.util.concurrent.TimeUnit unit)
Invokes
unit. sleep(sleepFor)
uninterruptibly. |
static <E> E |
takeUninterruptibly(java.util.concurrent.BlockingQueue<E> queue)
Invokes
queue. take() uninterruptibly. |
public static void awaitUninterruptibly(java.util.concurrent.CountDownLatch latch)
latch.
await()
uninterruptibly.public static boolean awaitUninterruptibly(java.util.concurrent.CountDownLatch latch, long timeout, java.util.concurrent.TimeUnit unit)
latch.
await(timeout, unit)
uninterruptibly.public static void joinUninterruptibly(java.lang.Thread toJoin)
toJoin.
join()
uninterruptibly.public static <V> V getUninterruptibly(java.util.concurrent.Future<V> future) throws java.util.concurrent.ExecutionException
future.
get()
uninterruptibly.
To get uninterruptibility and remove checked exceptions, see
Futures.getUnchecked(java.util.concurrent.Future<V>)
.
If instead, you wish to treat InterruptedException
uniformly
with other exceptions, see Futures.get
or Futures.makeChecked(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.base.Function<java.lang.Exception, X>)
.
java.util.concurrent.ExecutionException
- if the computation threw an exceptionCancellationException
- if the computation was cancelledpublic static <V> V getUninterruptibly(java.util.concurrent.Future<V> future, long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
future.
get(timeout, unit)
uninterruptibly.
If instead, you wish to treat InterruptedException
uniformly
with other exceptions, see Futures.get
or Futures.makeChecked(com.google.common.util.concurrent.ListenableFuture<V>, com.google.common.base.Function<java.lang.Exception, X>)
.
java.util.concurrent.ExecutionException
- if the computation threw an exceptionCancellationException
- if the computation was cancelledjava.util.concurrent.TimeoutException
- if the wait timed outpublic static void joinUninterruptibly(java.lang.Thread toJoin, long timeout, java.util.concurrent.TimeUnit unit)
unit.
timedJoin(toJoin, timeout)
uninterruptibly.public static <E> E takeUninterruptibly(java.util.concurrent.BlockingQueue<E> queue)
queue.
take()
uninterruptibly.public static <E> void putUninterruptibly(java.util.concurrent.BlockingQueue<E> queue, E element)
queue.
put(element)
uninterruptibly.java.lang.ClassCastException
- if the class of the specified element prevents
it from being added to the given queuejava.lang.IllegalArgumentException
- if some property of the specified element
prevents it from being added to the given queuepublic static void sleepUninterruptibly(long sleepFor, java.util.concurrent.TimeUnit unit)
unit.
sleep(sleepFor)
uninterruptibly.