Sketch Timer and implement Interrupt support
This commit is contained in:
35
include/PSX/Timer/timer.hpp
Normal file
35
include/PSX/Timer/timer.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __JABYENGINE_TIMER_HPP__
|
||||
#define __JABYENGINE_TIMER_HPP__
|
||||
#include "../jabyengine_defines.h"
|
||||
|
||||
namespace JabyEngine {
|
||||
class GlobalTime {
|
||||
public:
|
||||
class TimeStamp {
|
||||
private:
|
||||
size_t value;
|
||||
|
||||
constexpr TimeStamp(size_t value) : value(value) {}
|
||||
|
||||
public:
|
||||
constexpr size_t milliseconds_to(const TimeStamp& ts) const {
|
||||
return (ts.value - this->value);
|
||||
}
|
||||
|
||||
friend class GlobalTime;
|
||||
};
|
||||
|
||||
private:
|
||||
static size_t global_counter;
|
||||
|
||||
public:
|
||||
GlobalTime() = delete;
|
||||
~GlobalTime() = delete;
|
||||
|
||||
static TimeStamp get_time_stamp() {
|
||||
return TimeStamp(GlobalTime::global_counter);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //!__JABYENGINE_TIMER_HPP__
|
Reference in New Issue
Block a user