blob: c7fd02385ed4aba4aca5bb9182fa2206b7f6d06a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* \class storage::framework::Clock
* \ingroup clock
*
* \brief Class used to attain current time.
*
* This class wraps how the time is retrieved. A common clock is useful in order
* to let unit tests fake time. It is also useful to have one point for all
* time calculations, such that one can possibly optimize if time retrieval
* becomes a bottle neck.
*/
#pragma once
#include "time.h"
#include <memory>
namespace storage {
namespace framework {
struct Clock {
using UP = std::unique_ptr<Clock>;
virtual ~Clock() {}
virtual MicroSecTime getTimeInMicros() const = 0;
virtual MilliSecTime getTimeInMillis() const = 0;
virtual SecondTime getTimeInSeconds() const = 0;
// Time point resolution is intentionally not defined here.
virtual MonotonicTimePoint getMonotonicTime() const = 0;
};
} // framework
} // storage
|