summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/time_manager.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-01-20 06:05:24 +0100
committerbunnei <bunneidev@gmail.com>2021-01-29 06:42:26 +0100
commitc0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b (patch)
treee138e7d0ecb6a306261e2871fd0da405571deaab /src/core/hle/kernel/time_manager.cpp
parentcommon: common_funcs: Add useful kernel macro R_SUCCEED_IF. (diff)
downloadyuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.tar
yuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.tar.gz
yuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.tar.bz2
yuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.tar.lz
yuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.tar.xz
yuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.tar.zst
yuzu-c0f5830323ca5d5bdc2e5e494fcaeaf27fffeb6b.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/time_manager.cpp40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/core/hle/kernel/time_manager.cpp b/src/core/hle/kernel/time_manager.cpp
index aaeef3033..fd0630019 100644
--- a/src/core/hle/kernel/time_manager.cpp
+++ b/src/core/hle/kernel/time_manager.cpp
@@ -21,47 +21,27 @@ TimeManager::TimeManager(Core::System& system_) : system{system_} {
std::shared_ptr<KThread> thread;
{
std::lock_guard lock{mutex};
- const auto proper_handle = static_cast<Handle>(thread_handle);
- if (cancelled_events[proper_handle]) {
- return;
- }
- thread = system.Kernel().RetrieveThreadFromGlobalHandleTable(proper_handle);
- }
-
- if (thread) {
- // Thread can be null if process has exited
- thread->Wakeup();
+ thread = SharedFrom<KThread>(reinterpret_cast<KThread*>(thread_handle));
}
+ thread->Wakeup();
});
}
-void TimeManager::ScheduleTimeEvent(Handle& event_handle, KThread* timetask, s64 nanoseconds) {
+void TimeManager::ScheduleTimeEvent(KThread* thread, s64 nanoseconds) {
std::lock_guard lock{mutex};
- event_handle = timetask->GetGlobalHandle();
if (nanoseconds > 0) {
- ASSERT(timetask);
- ASSERT(timetask->GetState() != ThreadState::Runnable);
+ ASSERT(thread);
+ ASSERT(thread->GetState() != ThreadState::Runnable);
system.CoreTiming().ScheduleEvent(std::chrono::nanoseconds{nanoseconds},
- time_manager_event_type, event_handle);
- } else {
- event_handle = InvalidHandle;
- }
- cancelled_events[event_handle] = false;
-}
-
-void TimeManager::UnscheduleTimeEvent(Handle event_handle) {
- std::lock_guard lock{mutex};
- if (event_handle == InvalidHandle) {
- return;
+ time_manager_event_type,
+ reinterpret_cast<uintptr_t>(thread));
}
- system.CoreTiming().UnscheduleEvent(time_manager_event_type, event_handle);
- cancelled_events[event_handle] = true;
}
-void TimeManager::CancelTimeEvent(KThread* time_task) {
+void TimeManager::UnscheduleTimeEvent(KThread* thread) {
std::lock_guard lock{mutex};
- const Handle event_handle = time_task->GetGlobalHandle();
- UnscheduleTimeEvent(event_handle);
+ system.CoreTiming().UnscheduleEvent(time_manager_event_type,
+ reinterpret_cast<uintptr_t>(thread));
}
} // namespace Kernel