2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-11-10 04:02:11 +01:00
|
|
|
|
2022-12-18 22:50:02 +01:00
|
|
|
#include "core/hle/kernel/k_hardware_timer.h"
|
2021-11-10 04:02:11 +01:00
|
|
|
#include "core/hle/kernel/k_thread_queue.h"
|
|
|
|
#include "core/hle/kernel/kernel.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
void KThreadQueue::NotifyAvailable([[maybe_unused]] KThread* waiting_thread,
|
|
|
|
[[maybe_unused]] KSynchronizationObject* signaled_object,
|
2022-06-26 05:44:19 +02:00
|
|
|
[[maybe_unused]] Result wait_result) {}
|
2021-11-10 04:02:11 +01:00
|
|
|
|
2022-06-26 05:44:19 +02:00
|
|
|
void KThreadQueue::EndWait(KThread* waiting_thread, Result wait_result) {
|
2021-11-10 04:02:11 +01:00
|
|
|
// 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.
|
2022-12-18 22:50:02 +01:00
|
|
|
kernel.HardwareTimer().CancelTask(waiting_thread);
|
2021-11-10 04:02:11 +01:00
|
|
|
}
|
|
|
|
|
2022-06-26 05:44:19 +02:00
|
|
|
void KThreadQueue::CancelWait(KThread* waiting_thread, Result wait_result, bool cancel_timer_task) {
|
2021-11-10 04:02:11 +01:00
|
|
|
// 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) {
|
2022-12-18 22:50:02 +01:00
|
|
|
kernel.HardwareTimer().CancelTask(waiting_thread);
|
2021-11-10 04:02:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KThreadQueueWithoutEndWait::EndWait([[maybe_unused]] KThread* waiting_thread,
|
2022-06-26 05:44:19 +02:00
|
|
|
[[maybe_unused]] Result wait_result) {}
|
2021-11-10 04:02:11 +01:00
|
|
|
|
|
|
|
} // namespace Kernel
|