Interface Deadline
-
public interface Deadline
Common interface providing a deadline through the methodremainingTimeMillis()
.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
forceTimeout(Exception cause)
SearchTimeoutException
forceTimeoutAndCreateException(Exception cause)
static Deadline
ofMilliseconds(long milliseconds)
long
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, ornull
.- Throws:
SearchTimeoutException
- If the deadline is a hard deadline requiring immediate failure.
-
forceTimeoutAndCreateException
SearchTimeoutException forceTimeoutAndCreateException(Exception cause)
- Parameters:
cause
- The cause of the timeout, ornull
.- 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.
-
-