Class SessionTimingState

java.lang.Object
dev.deepcore.challenge.session.SessionTimingState

public final class SessionTimingState extends Object
Tracks run start and paused-duration timing values for a session.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    beginPause(long pausedAtMillis)
    Marks the timestamp when pause started.
    void
    beginRun(long startedAtMillis)
    Starts run timing at the provided millisecond timestamp.
    long
    Returns total accumulated paused duration in milliseconds.
    long
    Returns pause start timestamp in milliseconds.
    long
    Returns run start timestamp in milliseconds.
    void
    Resets all tracked timing values to zero.
    void
    restore(long runStartMs, long accumulatedPausedMs, long savedAtMs)
    Restores timing state from a persistent snapshot, advancing pause accumulation to account for lobby time since the run was saved.
    void
    resume(long resumedAtMillis)
    Resumes run timing and accumulates elapsed paused duration.

    Methods inherited from class java.lang.Object

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

    • SessionTimingState

      public SessionTimingState()
  • Method Details

    • restore

      public void restore(long runStartMs, long accumulatedPausedMs, long savedAtMs)
      Restores timing state from a persistent snapshot, advancing pause accumulation to account for lobby time since the run was saved.
      Parameters:
      runStartMs - original run start timestamp in milliseconds
      accumulatedPausedMs - total paused duration at the time the run was saved
      savedAtMs - wall-clock timestamp when the run was saved
    • reset

      public void reset()
      Resets all tracked timing values to zero.
    • beginRun

      public void beginRun(long startedAtMillis)
      Starts run timing at the provided millisecond timestamp.
      Parameters:
      startedAtMillis - timestamp in milliseconds when the run began
    • beginPause

      public void beginPause(long pausedAtMillis)
      Marks the timestamp when pause started.
      Parameters:
      pausedAtMillis - timestamp in milliseconds when pause began
    • resume

      public void resume(long resumedAtMillis)
      Resumes run timing and accumulates elapsed paused duration.
      Parameters:
      resumedAtMillis - timestamp in milliseconds when run resumed
    • getRunStartMillis

      public long getRunStartMillis()
      Returns run start timestamp in milliseconds.
      Returns:
      run start epoch timestamp in milliseconds
    • getPausedStartedMillis

      public long getPausedStartedMillis()
      Returns pause start timestamp in milliseconds.
      Returns:
      pause start epoch timestamp in milliseconds, or zero when not paused
    • getAccumulatedPausedMillis

      public long getAccumulatedPausedMillis()
      Returns total accumulated paused duration in milliseconds.
      Returns:
      total paused duration accumulated across all pause intervals