public class TimeoutTimer
extends java.lang.Object
| Constructor and Description |
|---|
TimeoutTimer(java.time.Duration initialTimeout)
Creates a new instance of the TimeoutTimer class.
|
TimeoutTimer(java.time.Duration initialTimeout,
java.util.function.Supplier<java.lang.Long> getNanos)
Creates a new instance of the TimeoutTimer class.
|
| Modifier and Type | Method and Description |
|---|---|
java.time.Duration |
getRemaining()
Calculates how much time is left of the original timeout.
|
boolean |
hasRemaining()
Returns true if there is time remaining.
|
void |
reset(java.time.Duration timeout)
Reset the timeout so that the original amount of time is remaining.
|
void |
zero()
Adjust the time so that the is no time remaining.
|
public TimeoutTimer(java.time.Duration initialTimeout)
initialTimeout - The initial timeout.public TimeoutTimer(java.time.Duration initialTimeout,
java.util.function.Supplier<java.lang.Long> getNanos)
initialTimeout - The initial timeout.getNanos - The supplier of nanoseconds.public java.time.Duration getRemaining()
public boolean hasRemaining()
public void reset(java.time.Duration timeout)
getRemaining(), the value returned by getRemaining()
may be wrong. A synchronized block is NOT required to avoid this.timeout - The duration from now which should be placed on the timer.public void zero()