Class Execution


  • public final class Execution
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean delay​(int minLength, int maxLength)
      Delays the current thread's execution for a length of time given in milliseconds between the minimum and maximum length
      static boolean delay​(int minLength, int maxLength, int averageLength)
      Delays the current thread's execution for a length of time between the minimum and maximum length, averaging around the averageLength
      static boolean delay​(long length)
      Delays the current thread's execution for the specified length of time in milliseconds
      static boolean delay​(long minLength, long maxLength)
      Delays the current thread's execution for a length of time given in milliseconds between the minimum and maximum length
      static boolean delay​(long minLength, long maxLength, long averageLength)
      Delays the current thread's execution for a length of time between the minimum and maximum length, averaging around the averageLength
      static void delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition)
      Delays until condition returns true.
      static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition, int timeout)
      Delays execution of the current thread until the condition is met (returns true) The current result will be checked every Math.min(100, timeout / 20) milliseconds (frequency) until the condition is met or the timeout is reached
      static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition, int minTimeout, int maxTimeout)  
      static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition, java.util.concurrent.Callable<java.lang.Boolean> reset, int timeout)  
      static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition, java.util.concurrent.Callable<java.lang.Boolean> reset, int minTimeout, int maxTimeout)  
      static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition, java.util.concurrent.Callable<java.lang.Boolean> reset, int frequency, int minTimeout, int maxTimeout)
      Delays execution of the current thread until the condition is met (returns true) The current result will be checked every X milliseconds (frequency) until the condition is met or the timeout is reached.
      static void delayUntilCycle​(int targetEngineCycle)  
      static void delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition)
      Delays while condition returns true.
      static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition, int timeout)  
      static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition, int minTimeout, int maxTimeout)  
      static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition, java.util.concurrent.Callable<java.lang.Boolean> reset, int timeout)  
      static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition, java.util.concurrent.Callable<java.lang.Boolean> reset, int minTimeout, int maxTimeout)  
      static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition, java.util.concurrent.Callable<java.lang.Boolean> reset, int frequency, int minTimeout, int maxTimeout)
      Delays execution of the current thread while the condition is met (returns true) The current result will be checked every X milliseconds (frequency) until the condition is met or the timeout is reached.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • delay

        public static boolean delay​(long length)
        Delays the current thread's execution for the specified length of time in milliseconds
        Parameters:
        length - The length of time to delay in milliseconds
        Returns:
        Whether we slept for the correct amount of time
      • delay

        public static boolean delay​(int minLength,
                                    int maxLength)
        Delays the current thread's execution for a length of time given in milliseconds between the minimum and maximum length
        Parameters:
        minLength - The minimum length in milliseconds (Inclusive)
        maxLength - The maximum length in milliseconds (Inclusive)
      • delay

        public static boolean delay​(int minLength,
                                    int maxLength,
                                    int averageLength)
        Delays the current thread's execution for a length of time between the minimum and maximum length, averaging around the averageLength
        Parameters:
        minLength - The minimum length in milliseconds (Inclusive)
        maxLength - The maximum length in milliseconds (Inclusive)
        averageLength - The average length of time in milliseconds to delay execution
      • delay

        public static boolean delay​(long minLength,
                                    long maxLength)
        Delays the current thread's execution for a length of time given in milliseconds between the minimum and maximum length
        Parameters:
        minLength - The minimum length in milliseconds (Inclusive)
        maxLength - The maximum length in milliseconds (Inclusive)
      • delay

        public static boolean delay​(long minLength,
                                    long maxLength,
                                    long averageLength)
        Delays the current thread's execution for a length of time between the minimum and maximum length, averaging around the averageLength
        Parameters:
        minLength - The minimum length in milliseconds (Inclusive)
        maxLength - The maximum length in milliseconds (Inclusive)
        averageLength - The average length of time in milliseconds to delay execution
      • delayUntil

        public static void delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition)
        Delays until condition returns true. Usage of this method is discouraged to the same extent as while loops. The advantage of this over a while loop is that it takes small pauses between calls to reduce cpu load.
        Parameters:
        condition -
      • delayUntil

        public static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         int timeout)
        Delays execution of the current thread until the condition is met (returns true) The current result will be checked every Math.min(100, timeout / 20) milliseconds (frequency) until the condition is met or the timeout is reached
        Parameters:
        condition - The condition that the thread will wait on
        timeout - The maximum amount of time to delay in milliseconds
      • delayUntil

        public static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         int minTimeout,
                                         int maxTimeout)
      • delayUntil

        public static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         java.util.concurrent.Callable<java.lang.Boolean> reset,
                                         int timeout)
      • delayUntil

        public static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         java.util.concurrent.Callable<java.lang.Boolean> reset,
                                         int minTimeout,
                                         int maxTimeout)
      • delayUntil

        public static boolean delayUntil​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         java.util.concurrent.Callable<java.lang.Boolean> reset,
                                         int frequency,
                                         int minTimeout,
                                         int maxTimeout)
        Delays execution of the current thread until the condition is met (returns true) The current result will be checked every X milliseconds (frequency) until the condition is met or the timeout is reached.
        Parameters:
        condition - The condition that the thread will wait on
        reset - A condition that will be used to reset the current time to 0
        frequency - The frequency that the condition is checked in milliseconds
        minTimeout - The minimum length of time in milliseconds that can pass before the method times out
        maxTimeout - The maximum length of time in milliseconds that can pass before the method times out
      • delayUntilCycle

        public static void delayUntilCycle​(int targetEngineCycle)
      • delayWhile

        public static void delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition)
        Delays while condition returns true. Usage of this method is discouraged to the same extent as while loops. The advantage of this over a while loop is that it takes small pauses between calls to reduce cpu load.
        Parameters:
        condition -
      • delayWhile

        public static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         int timeout)
      • delayWhile

        public static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         int minTimeout,
                                         int maxTimeout)
      • delayWhile

        public static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         java.util.concurrent.Callable<java.lang.Boolean> reset,
                                         int timeout)
      • delayWhile

        public static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         java.util.concurrent.Callable<java.lang.Boolean> reset,
                                         int minTimeout,
                                         int maxTimeout)
      • delayWhile

        public static boolean delayWhile​(java.util.concurrent.Callable<java.lang.Boolean> condition,
                                         java.util.concurrent.Callable<java.lang.Boolean> reset,
                                         int frequency,
                                         int minTimeout,
                                         int maxTimeout)
        Delays execution of the current thread while the condition is met (returns true) The current result will be checked every X milliseconds (frequency) until the condition is met or the timeout is reached.
        Parameters:
        condition - The condition that the thread will wait on
        reset - A condition that will be used to reset the current time to 0
        frequency - The frequency that the condition is checked in milliseconds
        minTimeout - The minimum length of time in milliseconds that can pass before the method times out
        maxTimeout - The maximum length of time in milliseconds that can pass before the method times out