java.lang.Object
com.apple.foundationdb.relational.util.Clocks

@API(EXPERIMENTAL) public final class Clocks extends Object
Utility class for creating different clock instances.
  • Method Details

    • systemClock

      public static Clock systemClock()
      Get a clock which reads nano time from the System clock.
      Returns:
      a clock which reads from the system clock.
    • logicalClock

      public static Clock logicalClock(@Nonnull AtomicLong ticker)
      Get a logical clock based off the specified underlying ticker object.

      When using a logical ticker, it is important that the clock not be set backwards (otherwise, algorithms may have weird results). This is a problem with all clocks, but is much more easily produced using logical clocks like this.

      Parameters:
      ticker - the underlying counter.
      Returns:
      a clock which uses the underlying ticker to tell logical time.