mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 11:13:57 +00:00
27 lines
437 B
C++
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() };
|
|
};
|
|
}
|