Files
windows-user-space-emulator/src/common/utils/timer.hpp
2024-08-18 18:50:38 +02:00

27 lines
437 B
C++

#pragma once
#include <chrono>
namespace utils
{
template <typename Clock = std::chrono::high_resolution_clock>
class timer
{
public:
void update()
{
this->point_ = Clock::now();
}
bool has_elapsed(typename Clock::duration duration) const
{
const auto now = Clock::now();
const auto diff = now - this->point_;
return diff > duration;
}
private:
typename Clock::time_point point_{ Clock::now() };
};
}