userver: userver/utils/impl/cached_time.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
cached_time.hpp
1#pragma once
2
3#include <chrono>
4#include <tuple>
5
6USERVER_NAMESPACE_BEGIN
7
8namespace utils::impl {
9
10using SystemTimePoint = std::chrono::system_clock::time_point;
11using SteadyTimePoint = std::chrono::steady_clock::time_point;
12
13// To serialize a steady_clock::time_point, we need to convert it to a
14// system_clock::time_point using now(). Calling now() myriad times in a row may
15// be costly, so as an optimization we cache now() globally.
16void UpdateGlobalTime();
17
18// Note: the two time points are not synchronized. They may also come from
19// different 'UpdateGlobalTime' calls.
20std::tuple<SystemTimePoint, SteadyTimePoint> GetGlobalTime();
21
22} // namespace utils::impl
23
24USERVER_NAMESPACE_END