kernel/timer: add TimerManager for timer system states

This commit is contained in:
Weiyi Wang 2018-10-23 14:17:30 -04:00
parent 20ae37ba4f
commit e5b93741d3
4 changed files with 49 additions and 28 deletions

View file

@ -5,11 +5,30 @@
#pragma once
#include "common/common_types.h"
#include "core/core_timing.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/wait_object.h"
namespace Kernel {
class TimerManager {
public:
TimerManager();
private:
/// The timer callback event, called when a timer is fired
void TimerCallback(u64 callback_id, s64 cycles_late);
/// The event type of the generic timer callback event
CoreTiming::EventType* timer_callback_event_type = nullptr;
u64 next_timer_callback_id = 0;
std::unordered_map<u64, Timer*> timer_callback_table;
friend class Timer;
friend class KernelSystem;
};
class Timer final : public WaitObject {
public:
std::string GetTypeName() const override {
@ -74,12 +93,9 @@ private:
/// ID used as userdata to reference this object when inserting into the CoreTiming queue.
u64 callback_id;
TimerManager& timer_manager;
friend class KernelSystem;
};
/// Initializes the required variables for timers
void TimersInit();
/// Tears down the timer variables
void TimersShutdown();
} // namespace Kernel