Common: improve native clock.

This commit is contained in:
Fernando Sahmkow 2021-11-23 03:29:00 +01:00
parent c78f6d4f20
commit 096366ead5
3 changed files with 29 additions and 29 deletions

View file

@ -3,6 +3,7 @@
#pragma once
#include <atomic>
#include "common/wall_clock.h"
namespace Common {
@ -28,13 +29,9 @@ public:
private:
u64 GetRTSC();
union alignas(16) TimePoint {
TimePoint() : pack{} {}
u128 pack{};
struct Inner {
u64 last_measure{};
u64 accumulated_ticks{};
} inner;
struct alignas(16) TimePoint {
u64 last_measure{};
u64 accumulated_ticks{};
};
/// value used to reduce the native clocks accuracy as some apss rely on
@ -42,7 +39,7 @@ private:
/// be higher.
static constexpr u64 inaccuracy_mask = ~(UINT64_C(0x400) - 1);
TimePoint time_point;
std::atomic<TimePoint> time_point;
// factors
u64 clock_rtsc_factor{};
u64 cpu_rtsc_factor{};