mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
Implement some syscalls
This commit is contained in:
26
src/common/utils/timer.hpp
Normal file
26
src/common/utils/timer.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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() };
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user