#pragma once #include #include #include #include namespace xrpl { /** Tracks program uptime to seconds precision. The timer caches the current time as a performance optimization. This allows clients to query the current time thousands of times per second. */ class UptimeClock { public: using rep = int; using period = std::ratio<1>; using duration = std::chrono::duration; using time_point = std::chrono::time_point; static constexpr bool is_steady = // NOLINT(readability-identifier-naming) std::chrono::system_clock::is_steady; explicit UptimeClock() = default; static time_point now(); // seconds since xrpld program start private: static std::atomic kNow; static std::atomic kStop; struct UpdateThread : private std::thread { ~UpdateThread(); UpdateThread(UpdateThread&&) = default; using std::thread::thread; }; static UpdateThread startClock(); }; } // namespace xrpl