Class EmbeddedEventLoop.FreezableTicker

java.lang.Object
io.netty.channel.embedded.EmbeddedEventLoop.FreezableTicker
All Implemented Interfaces:
MockTicker, Ticker
Enclosing class:
EmbeddedEventLoop

static final class EmbeddedEventLoop.FreezableTicker extends Object implements MockTicker
Ticker that implements the old EmbeddedChannel time freezing mechanics.
  • Field Details

    • unfrozen

      private final Ticker unfrozen
    • startTime

      private long startTime
      When time is not frozen, the base time to subtract from System.nanoTime(). When time is frozen, this variable is unused.
    • frozenTimestamp

      private long frozenTimestamp
      When time is frozen, the timestamp returned by EmbeddedEventLoop.getCurrentTimeNanos(). When unfrozen, this is unused.
    • timeFrozen

      private boolean timeFrozen
      Whether time is currently frozen.
  • Constructor Details

    • FreezableTicker

      FreezableTicker()
  • Method Details

    • advance

      public void advance(long amount, TimeUnit unit)
      Description copied from interface: MockTicker
      Advances the current Ticker.nanoTime() by the given amount of time.
      Specified by:
      advance in interface MockTicker
      Parameters:
      amount - the amount of time to advance this ticker by.
      unit - the TimeUnit of amount.
    • nanoTime

      public long nanoTime()
      Description copied from interface: Ticker
      The time elapsed since initialization of this class in nanoseconds. This may return a negative number just like System.nanoTime().
      Specified by:
      nanoTime in interface Ticker
    • sleep

      public void sleep(long delay, TimeUnit unit) throws InterruptedException
      Description copied from interface: Ticker
      Waits until the given amount of time goes by.
      Specified by:
      sleep in interface Ticker
      Parameters:
      delay - the amount of delay.
      unit - the TimeUnit of delay.
      Throws:
      InterruptedException
      See Also:
    • freezeTime

      public void freezeTime()
    • unfreezeTime

      public void unfreezeTime()