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 java.lang.Object implements MockTicker
Ticker that implements the old EmbeddedChannel time freezing mechanics.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
    When time is frozen, the timestamp returned by EmbeddedEventLoop.getCurrentTimeNanos().
    private long
    When time is not frozen, the base time to subtract from System.nanoTime().
    private boolean
    Whether time is currently frozen.
    private final Ticker
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    advance(long amount, java.util.concurrent.TimeUnit unit)
    Advances the current Ticker.nanoTime() by the given amount of time.
    void
     
    long
    The time elapsed since initialization of this class in nanoseconds.
    void
    sleep(long delay, java.util.concurrent.TimeUnit unit)
    Waits until the given amount of time goes by.
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface MockTicker

    advanceMillis, initialNanoTime

    Methods inherited from interface Ticker

    sleepMillis
  • 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, java.util.concurrent.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, java.util.concurrent.TimeUnit unit) throws java.lang.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:
      java.lang.InterruptedException
      See Also:
      • Thread.sleep(long)
    • freezeTime

      public void freezeTime()
    • unfreezeTime

      public void unfreezeTime()