diff options
Diffstat (limited to 'src/core/hle/kernel/timer.cpp')
-rw-r--r-- | src/core/hle/kernel/timer.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 3b0452d4..ec0b2c32 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -13,7 +13,7 @@ namespace Kernel { -class Timer : public Object { +class Timer : public WaitObject { public: std::string GetTypeName() const override { return "Timer"; } std::string GetName() const override { return name; } @@ -24,19 +24,17 @@ public: ResetType reset_type; ///< The ResetType of this timer bool signaled; ///< Whether the timer has been signaled or not - std::set<Handle> waiting_threads; ///< Threads that are waiting for the timer std::string name; ///< Name of timer (optional) u64 initial_delay; ///< The delay until the timer fires for the first time u64 interval_delay; ///< The delay until the timer fires after the first time - ResultVal<bool> WaitSynchronization() override { - bool wait = !signaled; - if (wait) { - waiting_threads.insert(GetCurrentThread()->GetHandle()); - Kernel::WaitCurrentThread(WAITTYPE_TIMER, this); - } - return MakeResult<bool>(wait); + bool ShouldWait() override { + return !signaled; + } + + void Acquire() override { + _assert_msg_(Kernel, !ShouldWait(), "object unavailable!"); } }; @@ -92,12 +90,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) { timer->signaled = true; // Resume all waiting threads - for (Handle thread_handle : timer->waiting_threads) { - if (SharedPtr<Thread> thread = Kernel::g_handle_table.Get<Thread>(thread_handle)) - thread->ResumeFromWait(); - } - - timer->waiting_threads.clear(); + timer->WakeupAllWaitingThreads(); if (timer->reset_type == RESETTYPE_ONESHOT) timer->signaled = false; |