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