diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-31 17:23:09 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-02-02 18:37:03 +0100 |
commit | a9b86db3cfec5ce907051d6730ffd98c0fd03876 (patch) | |
tree | 791877de9d2a746a5a73e32a3bb3110670cff91a /src/core/hle/kernel/timer.cpp | |
parent | Kernel: Remove previous scheduled event when a Timer is re-Set (diff) | |
download | yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.gz yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.bz2 yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.lz yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.xz yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.zst yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.zip |
Diffstat (limited to 'src/core/hle/kernel/timer.cpp')
-rw-r--r-- | src/core/hle/kernel/timer.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 794be060c..90e5e64b3 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <set> - #include "common/common.h" #include "core/core_timing.h" @@ -15,6 +13,9 @@ namespace Kernel { /// The event type of the generic timer callback event static int timer_callback_event_type = -1; +// TODO(yuriks): This can be removed if Timer objects are explicitly pooled in the future, allowing +// us to simply use a pool index or similar. +static Kernel::HandleTable timer_callback_handle_table; ResultVal<SharedPtr<Timer>> Timer::Create(ResetType reset_type, std::string name) { SharedPtr<Timer> timer(new Timer); @@ -26,6 +27,7 @@ ResultVal<SharedPtr<Timer>> Timer::Create(ResetType reset_type, std::string name timer->name = std::move(name); timer->initial_delay = 0; timer->interval_delay = 0; + timer->callback_handle = timer_callback_handle_table.Create(timer).MoveFrom(); return MakeResult<SharedPtr<Timer>>(timer); } @@ -45,13 +47,12 @@ void Timer::Set(s64 initial, s64 interval) { interval_delay = interval; u64 initial_microseconds = initial / 1000; - // TODO(yuriks): Figure out a replacement for GetHandle here - CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), timer_callback_event_type, - GetHandle()); + CoreTiming::ScheduleEvent(usToCycles(initial_microseconds), + timer_callback_event_type, callback_handle); } void Timer::Cancel() { - CoreTiming::UnscheduleEvent(timer_callback_event_type, GetHandle()); + CoreTiming::UnscheduleEvent(timer_callback_event_type, callback_handle); } void Timer::Clear() { @@ -60,7 +61,7 @@ void Timer::Clear() { /// The timer callback event, called when a timer is fired static void TimerCallback(u64 timer_handle, int cycles_late) { - SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(timer_handle); + SharedPtr<Timer> timer = timer_callback_handle_table.Get<Timer>(timer_handle); if (timer == nullptr) { LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08X", timer_handle); |