Class TimerTable

java.lang.Object
io.github.mahmoudimus.quic.connection.TimerTable

public final class TimerTable extends Object
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 Details

    • TimerTable

      public TimerTable()
      A table with no timer set.
  • Method Details

    • set

      public void set(Timer timer, long time)
      Sets a timer.
      Parameters:
      timer - the timer
      time - its deadline
    • get

      public long get(Timer timer)
      A timer's deadline.
      Parameters:
      timer - the timer
      Returns:
      the deadline, or NanoClock.NONE if it is not set
    • isSet

      public boolean isSet(Timer timer)
      Whether a timer is set.
      Parameters:
      timer - the timer
      Returns:
      true if it has a deadline
    • stop

      public void stop(Timer timer)
      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.NONE if no timer is set
    • isExpired

      public boolean isExpired(Timer timer, long now)
      Whether a timer has expired.
      Parameters:
      timer - the timer
      now - the current time
      Returns:
      true if it is set and its deadline is at or before now
    • pollExpired

      public Timer pollExpired(long now)
      Stops and returns the first expired timer, in Timer order.
      Parameters:
      now - the current time
      Returns:
      the timer, or null if none has expired