clock.h 723 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include <util/datetime/base.h>
  3. #include <atomic>
  4. namespace NUnifiedAgent {
  5. class TClock {
  6. public:
  7. static void Configure();
  8. static inline bool Configured() {
  9. return Configured_;
  10. }
  11. static inline TInstant Now() {
  12. return Configured_ ? Get() : TInstant::Now();
  13. }
  14. static void SetBase(TInstant value);
  15. static void ResetBase();
  16. static void ResetBaseWithShift();
  17. static void SetShift(TDuration value);
  18. static void ResetShift();
  19. static TInstant Get();
  20. private:
  21. static bool Configured_;
  22. static std::atomic<ui64> Base_;
  23. static std::atomic<i64> Shift_;
  24. };
  25. }