Class TimerTable
java.lang.Object
io.github.mahmoudimus.quic.connection.TimerTable
The deadline of each
Timer, in nanoseconds from the connection's NanoClock. The
connection layer sleeps until nextTimeout(), then handles each timer pollExpired(long) returns.
Threads. Not thread-safe; owned by one connection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongA timer's deadline.booleanWhether a timer has expired.booleanWhether a timer is set.longThe earliest deadline.pollExpired(long now) Stops and returns the first expired timer, inTimerorder.voidSets a timer.voidStops a timer.voidstopAll()Stops every timer, as when the connection is closed.
-
Constructor Details
-
TimerTable
public TimerTable()A table with no timer set.
-
-
Method Details
-
set
Sets a timer.- Parameters:
timer- the timertime- its deadline
-
get
A timer's deadline.- Parameters:
timer- the timer- Returns:
- the deadline, or
NanoClock.NONEif it is not set
-
isSet
Whether a timer is set.- Parameters:
timer- the timer- Returns:
- true if it has a deadline
-
stop
Stops a timer.- Parameters:
timer- the timer
-
stopAll
public void stopAll()Stops every timer, as when the connection is closed. -
nextTimeout
public long nextTimeout()The earliest deadline.- Returns:
- the time, or
NanoClock.NONEif no timer is set
-
isExpired
Whether a timer has expired.- Parameters:
timer- the timernow- the current time- Returns:
- true if it is set and its deadline is at or before
now
-
pollExpired
Stops and returns the first expired timer, inTimerorder.- Parameters:
now- the current time- Returns:
- the timer, or null if none has expired
-