Interface Deadline


  • public interface Deadline
    Common interface providing a deadline through the method remainingTimeMillis().
    • Method Detail

      • remainingTimeMillis

        long remainingTimeMillis()
        Returns:
        The remaining time to the deadline in milliseconds.
        Throws:
        SearchTimeoutException - If the deadline was reached and it's a hard deadline requiring immediate failure.
      • forceTimeout

        void forceTimeout​(Exception cause)
        Parameters:
        cause - The cause of the timeout, or null.
        Throws:
        SearchTimeoutException - If the deadline is a hard deadline requiring immediate failure.
      • forceTimeoutAndCreateException

        SearchTimeoutException forceTimeoutAndCreateException​(Exception cause)
        Parameters:
        cause - The cause of the timeout, or null.
        Returns:
        An exception to be thrown on timeout.
      • ofMilliseconds

        static Deadline ofMilliseconds​(long milliseconds)
        Parameters:
        milliseconds - The number of milliseconds until the deadline.
        Returns:
        An immutable Deadline which does not track the passing time. remainingTimeMillis() will always return the same value and will never throw an exception.