Package io.ably.lib.util

Class SystemClock

java.lang.Object
io.ably.lib.util.SystemClock
All Implemented Interfaces:
Clock

public class SystemClock extends Object implements Clock
  • Field Details

  • Constructor Details

    • SystemClock

      public SystemClock()
  • Method Details

    • currentTimeMillis

      public long currentTimeMillis()
      Description copied from interface: Clock
      Returns the current wall-clock time in milliseconds since the Unix epoch (1 January 1970 00:00:00 UTC), analogous to System.currentTimeMillis().
      Specified by:
      currentTimeMillis in interface Clock
      Returns:
      current time in milliseconds
    • nanoTime

      public long nanoTime()
      Description copied from interface: Clock
      Returns the current wall-clock time in nanoseconds since the Unix epoch (1 January 1970 00:00:00 UTC), analogous to System.nanoTime().
      Specified by:
      nanoTime in interface Clock
      Returns:
      current time in nanoseconds
    • newTimer

      public AblyTimer newTimer(String name)
      Description copied from interface: Clock
      Creates a new AblyTimer backed by this clock.

      The name is used for diagnostic and logging purposes (e.g. as the underlying Timer thread name).

      Specified by:
      newTimer in interface Clock
      Parameters:
      name - a human-readable label for the timer; must not be null
      Returns:
      a new AblyTimer instance ready to schedule tasks
    • waitOn

      public void waitOn(Object target, long timeout) throws InterruptedException
      Description copied from interface: Clock
      Causes the current thread to wait until either another thread calls Object.notify() / Object.notifyAll() on target, or the specified timeout elapses — analogous to Object.wait(long).

      The caller must hold the monitor of target before invoking this method, exactly as required by Object.wait(long).

      Specified by:
      waitOn in interface Clock
      Parameters:
      target - the object whose monitor the current thread holds and will wait on; must not be null
      timeout - maximum time to wait in milliseconds; 0 means wait indefinitely
      Throws:
      InterruptedException - if the current thread is interrupted while waiting
    • clockFrom

      public static Clock clockFrom(ClientOptions opts)