k_thread_queue.cpp 1.6 KB

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