Changeset View
Changeset View
Standalone View
Standalone View
src/util/time.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | template <typename T> static T GetSystemTime() { | ||||
return now; | return now; | ||||
} | } | ||||
void SetMockTime(int64_t nMockTimeIn) { | void SetMockTime(int64_t nMockTimeIn) { | ||||
Assert(nMockTimeIn >= 0); | Assert(nMockTimeIn >= 0); | ||||
nMockTime.store(nMockTimeIn, std::memory_order_relaxed); | nMockTime.store(nMockTimeIn, std::memory_order_relaxed); | ||||
} | } | ||||
int64_t GetMockTime() { | std::chrono::seconds GetMockTime() { | ||||
return nMockTime.load(std::memory_order_relaxed); | return std::chrono::seconds(nMockTime.load(std::memory_order_relaxed)); | ||||
} | } | ||||
int64_t GetTimeMillis() { | int64_t GetTimeMillis() { | ||||
return int64_t{GetSystemTime<std::chrono::milliseconds>().count()}; | return int64_t{GetSystemTime<std::chrono::milliseconds>().count()}; | ||||
} | } | ||||
int64_t GetTimeMicros() { | int64_t GetTimeMicros() { | ||||
return int64_t{GetSystemTime<std::chrono::microseconds>().count()}; | return int64_t{GetSystemTime<std::chrono::microseconds>().count()}; | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |