Class Uninterruptibles

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static <V> V getUninterruptibly​(java.util.concurrent.Future<V> future)
      Invokes future.get() uninterruptibly.
      (package private) static <V> V getUninterruptibly​(java.util.concurrent.Future<V> future, long timeout, java.util.concurrent.TimeUnit unit)
      Invokes future.get(timeout, unit) uninterruptibly.
      (package private) static <V> V getUninterruptibly​(java.util.concurrent.Future<V> future, java.time.Duration timeout)
      Invokes future.get(timeout, unit) uninterruptibly.
      private static long saturatedToNanos​(java.time.Duration duration)
      Returns the number of nanoseconds of the given duration without throwing or overflowing.
      (package private) static void shutdownUninterruptibly​(java.util.concurrent.ExecutorService executor, long timeout, java.util.concurrent.TimeUnit unit)
      Shuts down an executor service uninterruptedly Note that this method is created by Johan Haleby and is thus not covered by the Guava license
      (package private) static void sleepUninterruptibly​(long sleepFor, java.util.concurrent.TimeUnit unit)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Uninterruptibles

        Uninterruptibles()
    • Method Detail

      • sleepUninterruptibly

        static void sleepUninterruptibly​(long sleepFor,
                                         java.util.concurrent.TimeUnit unit)
      • getUninterruptibly

        static <V> V getUninterruptibly​(java.util.concurrent.Future<V> future)
                                 throws java.util.concurrent.ExecutionException
        Invokes future.get() uninterruptibly.
        Throws:
        java.util.concurrent.ExecutionException - if the computation threw an exception
        java.util.concurrent.CancellationException - if the computation was cancelled
      • getUninterruptibly

        static <V> V getUninterruptibly​(java.util.concurrent.Future<V> future,
                                        java.time.Duration timeout)
                                 throws java.util.concurrent.ExecutionException,
                                        java.util.concurrent.TimeoutException
        Invokes future.get(timeout, unit) uninterruptibly.
        Throws:
        java.util.concurrent.ExecutionException - if the computation threw an exception
        java.util.concurrent.CancellationException - if the computation was cancelled
        java.util.concurrent.TimeoutException - if the wait timed out
      • getUninterruptibly

        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
        Invokes future.get(timeout, unit) uninterruptibly.
        Throws:
        java.util.concurrent.ExecutionException - if the computation threw an exception
        java.util.concurrent.CancellationException - if the computation was cancelled
        java.util.concurrent.TimeoutException - if the wait timed out
      • shutdownUninterruptibly

        static void shutdownUninterruptibly​(java.util.concurrent.ExecutorService executor,
                                            long timeout,
                                            java.util.concurrent.TimeUnit unit)
        Shuts down an executor service uninterruptedly Note that this method is created by Johan Haleby and is thus not covered by the Guava license
        Parameters:
        executor - The executor service to shut down
        timeout - The timeout amount
        unit - The time unit
      • saturatedToNanos

        private static long saturatedToNanos​(java.time.Duration duration)
        Returns the number of nanoseconds of the given duration without throwing or overflowing.

        Instead of throwing ArithmeticException, this method silently saturates to either Long.MAX_VALUE or Long.MIN_VALUE. This behavior can be useful when decomposing a duration in order to call a legacy API which requires a long, TimeUnit pair.