Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 1 | #pragma once |
2 | |||||
3 | #include "interfaces/clock.hpp" | ||||
4 | #include "types/duration_type.hpp" | ||||
5 | |||||
6 | #include <chrono> | ||||
7 | |||||
8 | class Clock : public interfaces::Clock | ||||
9 | { | ||||
10 | public: | ||||
11 | time_point now() const noexcept override | ||||
12 | { | ||||
13 | return std::chrono::steady_clock::now(); | ||||
14 | } | ||||
15 | |||||
16 | uint64_t timestamp() const noexcept override | ||||
17 | { | ||||
18 | return std::chrono::time_point_cast<Milliseconds>(now()) | ||||
19 | .time_since_epoch() | ||||
20 | .count(); | ||||
21 | } | ||||
22 | }; |