Class CachedEpochClock

java.lang.Object
org.agrona.concurrent.CachedEpochClock
All Implemented Interfaces:
EpochClock

public class CachedEpochClock extends Object implements EpochClock
An EpochClock that caches a timestamp which can be updated with update(long).

Instances are threadsafe with the read being volatile.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected long
    Time in milliseconds.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    advance(long millis)
    Advance the value of the timestamp in with release ordered semantics.
    long
    Time in milliseconds since 1 Jan 1970 UTC.
    void
    update(long timeMs)
    Update the value of the timestamp in with release ordered semantics.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • timeMs

      protected volatile long timeMs
      Time in milliseconds.
  • Constructor Details

    • CachedEpochClock

      public CachedEpochClock()
      Create a new instance.
  • Method Details

    • time

      public long time()
      Time in milliseconds since 1 Jan 1970 UTC.
      Specified by:
      time in interface EpochClock
      Returns:
      the number of milliseconds since 1 Jan 1970 UTC.
      See Also:
    • update

      public void update(long timeMs)
      Update the value of the timestamp in with release ordered semantics.
      Parameters:
      timeMs - value to update the timestamp.
    • advance

      public void advance(long millis)
      Advance the value of the timestamp in with release ordered semantics.
      Parameters:
      millis - to advance the timestamp.