39 lines
710 B
C++
39 lines
710 B
C++
#pragma once
|
|
#include "thread/Timer.h"
|
|
#include <bits/timespec.h>
|
|
|
|
struct Clock
|
|
{
|
|
static void init();
|
|
static void arch_init();
|
|
|
|
void set_resolution(long resolution);
|
|
|
|
void update(const struct timespec& time);
|
|
|
|
void tick();
|
|
|
|
void add_to_timer_queue(Timer* timer);
|
|
void remove_from_timer_queue(Timer* timer);
|
|
|
|
void get_time(struct timespec& out);
|
|
long resolution();
|
|
|
|
struct timespec from_ticks(u64 ticks);
|
|
|
|
u64 ticks_left(Timer* timer);
|
|
|
|
private:
|
|
struct timespec m_time
|
|
{
|
|
.tv_sec = 0, .tv_nsec = 0
|
|
};
|
|
|
|
long m_resolution = 1'000'000'000;
|
|
|
|
LinkedList<Timer> m_timer_queue;
|
|
};
|
|
|
|
extern Clock g_realtime_clock;
|
|
extern Clock g_monotonic_clock;
|