k_thread_queue.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "core/hle/kernel/k_hardware_timer.h"
  4. #include "core/hle/kernel/k_thread_queue.h"
  5. #include "core/hle/kernel/kernel.h"
  6. namespace Kernel {
  7. void KThreadQueue::NotifyAvailable(KThread* waiting_thread, KSynchronizationObject* signaled_object,
  8. Result wait_result) {
  9. UNREACHABLE();
  10. }
  11. void KThreadQueue::EndWait(KThread* waiting_thread, Result wait_result) {
  12. // Set the thread's wait result.
  13. waiting_thread->SetWaitResult(wait_result);
  14. // Set the thread as runnable.
  15. waiting_thread->SetState(ThreadState::Runnable);
  16. // Clear the thread's wait queue.
  17. waiting_thread->ClearWaitQueue();
  18. // Cancel the thread task.
  19. if (m_hardware_timer != nullptr) {
  20. m_hardware_timer->CancelTask(waiting_thread);
  21. }
  22. }
  23. void KThreadQueue::CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) {
  24. // Set the thread's wait result.
  25. waiting_thread->SetWaitResult(wait_result);
  26. // Set the thread as runnable.
  27. waiting_thread->SetState(ThreadState::Runnable);
  28. // Clear the thread's wait queue.
  29. waiting_thread->ClearWaitQueue();
  30. // Cancel the thread task.
  31. if (cancel_timer_task && m_hardware_timer != nullptr) {
  32. m_hardware_timer->CancelTask(waiting_thread);
  33. }
  34. }
  35. void KThreadQueueWithoutEndWait::EndWait(KThread* waiting_thread, Result wait_result) {
  36. UNREACHABLE();
  37. }
  38. } // namespace Kernel