diff options
| author | bunnei <bunneidev@gmail.com> | 2021-12-12 22:43:25 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-12 22:43:25 -0800 |
| commit | 5273e0665eaba209c0cf06a9a0d3e884098357fc (patch) | |
| tree | 49a3ef8127d721dc44effb8315e5db7e796336f4 /src/core/hle/kernel/k_thread_queue.cpp | |
| parent | 16fa8e0b370348dfb4d9fd8f3386cdfeb47b8a52 (diff) | |
| parent | 5788e077cd60934ddfbf9a3f8bb46d043ceed897 (diff) | |
Merge pull request #7462 from bunnei/kernel-improve-scheduling
Kernel: Improve threading & scheduling V3
Diffstat (limited to 'src/core/hle/kernel/k_thread_queue.cpp')
| -rw-r--r-- | src/core/hle/kernel/k_thread_queue.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_thread_queue.cpp b/src/core/hle/kernel/k_thread_queue.cpp new file mode 100644 index 0000000000..46f27172bc --- /dev/null +++ b/src/core/hle/kernel/k_thread_queue.cpp @@ -0,0 +1,51 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/kernel/k_thread_queue.h" +#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/time_manager.h" + +namespace Kernel { + +void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread, + [[maybe_unused]] KSynchronizationObject* signaled_object, + [[maybe_unused]] ResultCode wait_result) {} + +void KThreadQueue::EndWait(KThread* waiting_thread, ResultCode wait_result) { + // Set the thread's wait result. + waiting_thread->SetWaitResult(wait_result); + + // Set the thread as runnable. + waiting_thread->SetState(ThreadState::Runnable); + + // Clear the thread's wait queue. + waiting_thread->ClearWaitQueue(); + + // Cancel the thread task. + kernel.TimeManager().UnscheduleTimeEvent(waiting_thread); +} + +void KThreadQueue::CancelWait(KThread* waiting_thread, ResultCode wait_result, + bool cancel_timer_task) { + // Set the thread's wait result. + waiting_thread->SetWaitResult(wait_result); + + // Set the thread as runnable. + waiting_thread->SetState(ThreadState::Runnable); + + // Clear the thread's wait queue. + waiting_thread->ClearWaitQueue(); + + // Cancel the thread task. + if (cancel_timer_task) { + kernel.TimeManager().UnscheduleTimeEvent(waiting_thread); + } +} + +void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread, + [[maybe_unused]] ResultCode wait_result) {} + +} // namespace Kernel |
