diff options
author | bunnei <bunneidev@gmail.com> | 2022-01-18 03:08:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 03:08:24 +0100 |
commit | 101d86897b729ca66caf7cfee246e6f238ecf723 (patch) | |
tree | 92b516dd4958ca01bb5544a475011a2634412132 /src/core/hle/kernel/k_worker_task_manager.cpp | |
parent | Merge pull request #7724 from ameerj/astc_new_nv (diff) | |
parent | core: hle: kernel: KThread: Integrate with KWorkerTask and implement DoWorkerTaskImpl. (diff) | |
download | yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.tar yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.tar.gz yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.tar.bz2 yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.tar.lz yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.tar.xz yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.tar.zst yuzu-101d86897b729ca66caf7cfee246e6f238ecf723.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/k_worker_task_manager.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_worker_task_manager.cpp b/src/core/hle/kernel/k_worker_task_manager.cpp new file mode 100644 index 000000000..785e08111 --- /dev/null +++ b/src/core/hle/kernel/k_worker_task_manager.cpp @@ -0,0 +1,42 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/assert.h" +#include "core/hle/kernel/k_process.h" +#include "core/hle/kernel/k_thread.h" +#include "core/hle/kernel/k_worker_task.h" +#include "core/hle/kernel/k_worker_task_manager.h" +#include "core/hle/kernel/kernel.h" + +namespace Kernel { + +KWorkerTask::KWorkerTask(KernelCore& kernel_) : KSynchronizationObject{kernel_} {} + +void KWorkerTask::DoWorkerTask() { + if (auto* const thread = this->DynamicCast<KThread*>(); thread != nullptr) { + return thread->DoWorkerTaskImpl(); + } else { + auto* const process = this->DynamicCast<KProcess*>(); + ASSERT(process != nullptr); + + return process->DoWorkerTaskImpl(); + } +} + +KWorkerTaskManager::KWorkerTaskManager() : m_waiting_thread(1, "yuzu:KWorkerTaskManager") {} + +void KWorkerTaskManager::AddTask(KernelCore& kernel, WorkerType type, KWorkerTask* task) { + ASSERT(type <= WorkerType::Count); + kernel.WorkerTaskManager().AddTask(kernel, task); +} + +void KWorkerTaskManager::AddTask(KernelCore& kernel, KWorkerTask* task) { + KScopedSchedulerLock sl(kernel); + m_waiting_thread.QueueWork([task]() { + // Do the task. + task->DoWorkerTask(); + }); +} + +} // namespace Kernel |