Interface CyclicTimeouts.Expirable
- All Known Subinterfaces:
DoSHandler.Tracker
- All Known Implementing Classes:
AbstractStream, HTTP2Stream, HTTP3Stream, HttpChannel, HttpExchange, QuicheStream
- Enclosing class:
CyclicTimeouts<T extends CyclicTimeouts.Expirable>
public static interface CyclicTimeouts.Expirable
An entity that may expire.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longcalcExpireNanoTime(long timeoutMs) Calculates the expiration time in nanoseconds.longReturns the expiration time in nanoseconds.
-
Method Details
-
getExpireNanoTime
long getExpireNanoTime()Returns the expiration time in nanoseconds.
The value to return must be calculated taking into account the current nanoTime, for example:
expireNanoTime = NanoTime.now() + timeoutNanosReturning
Long.MAX_VALUEindicates that this entity does not expire.- Returns:
- the expiration time in nanoseconds, or
Long.MAX_VALUEif this entity does not expire
-
calcExpireNanoTime
static long calcExpireNanoTime(long timeoutMs) Calculates the expiration time in nanoseconds.
If the given
timeoutMsis positive, the returned value is calculated from the current nanoTime:NanoTime.now() + TimeUnit.MILLISECONDS.toNanos(timeoutMs). If the calculated value isLong.MAX_VALUE, then an additional nanosecond is added to avoid ever returningLong.MAX_VALUEwhentimeoutMsis positive.If the given
timeoutMsis zero or negative,Long.MAX_VALUEis returned.- Parameters:
timeoutMs- the timeout to add to the current nanoTime to calculate the expiration time- Returns:
- the expiration time in nanoseconds, or
Long.MAX_VALUEif the timeout is zero or negative
-