1
#pragma once
2

            
3
#include <chrono>
4

            
5
#include "envoy/common/pure.h"
6

            
7
namespace Envoy {
8

            
9
/**
10
 * Less typing for common system time and steady time type.
11
 *
12
 * SystemTime should be used when getting a time to present to the user, e.g. for logging.
13
 * MonotonicTime should be used when tracking time for computing an interval.
14
 */
15
using Seconds = std::chrono::seconds;
16
using SystemTime = std::chrono::time_point<std::chrono::system_clock>;
17
using MonotonicTime = std::chrono::time_point<std::chrono::steady_clock>;
18

            
19
/**
20
 * Captures a system-time source, capable of computing both monotonically increasing
21
 * and real time.
22
 */
23
class TimeSource {
24
public:
25
566190
  virtual ~TimeSource() = default;
26

            
27
  /**
28
   * @return the current system time; not guaranteed to be monotonically increasing.
29
   */
30
  virtual SystemTime systemTime() PURE;
31
  /**
32
   * @return the current monotonic time.
33
   */
34
  virtual MonotonicTime monotonicTime() PURE;
35
};
36

            
37
} // namespace Envoy