VERY experimental Nintendo Switch 2 emulator
C++
Kernel: Remove unused ConditionVariable class.
Subvf5a2b1920bf8
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex c1a645460c..b3807c2040 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -42,8 +42,6 @@ add_library(core STATIChle/kernel/client_port.hhle/kernel/client_session.cpphle/kernel/client_session.h- hle/kernel/condition_variable.cpp- hle/kernel/condition_variable.hhle/kernel/errors.hhle/kernel/event.cpphle/kernel/event.hdiff --git a/src/core/hle/kernel/condition_variable.cpp b/src/core/hle/kernel/condition_variable.cppdeleted file mode 100644index a786d7f740..0000000000--- a/src/core/hle/kernel/condition_variable.cpp+++ /dev/null@@ -1,64 +0,0 @@-// Copyright 2018 yuzu emulator team-// Licensed under GPLv2 or any later version-// Refer to the license.txt file included.--#include "common/assert.h"-#include "core/hle/kernel/condition_variable.h"-#include "core/hle/kernel/errors.h"-#include "core/hle/kernel/kernel.h"-#include "core/hle/kernel/object_address_table.h"-#include "core/hle/kernel/thread.h"--namespace Kernel {--ConditionVariable::ConditionVariable() {}-ConditionVariable::~ConditionVariable() {}--ResultVal<SharedPtr<ConditionVariable>> ConditionVariable::Create(VAddr guest_addr,- std::string name) {- SharedPtr<ConditionVariable> condition_variable(new ConditionVariable);-- condition_variable->name = std::move(name);- condition_variable->guest_addr = guest_addr;- condition_variable->mutex_addr = 0;-- // Condition variables are referenced by guest address, so track this in the kernel- g_object_address_table.Insert(guest_addr, condition_variable);-- return MakeResult<SharedPtr<ConditionVariable>>(std::move(condition_variable));-}--bool ConditionVariable::ShouldWait(Thread* thread) const {- return GetAvailableCount() <= 0;-}--void ConditionVariable::Acquire(Thread* thread) {- if (GetAvailableCount() <= 0)- return;-- SetAvailableCount(GetAvailableCount() - 1);-}--ResultCode ConditionVariable::Release(s32 target) {- if (target == -1) {- // When -1, wake up all waiting threads- SetAvailableCount(static_cast<s32>(GetWaitingThreads().size()));- WakeupAllWaitingThreads();- } else {- // Otherwise, wake up just a single thread- SetAvailableCount(target);- WakeupWaitingThread(GetHighestPriorityReadyThread());- }-- return RESULT_SUCCESS;-}--s32 ConditionVariable::GetAvailableCount() const {- return Memory::Read32(guest_addr);-}--void ConditionVariable::SetAvailableCount(s32 value) const {- Memory::Write32(guest_addr, value);-}--} // namespace Kerneldiff --git a/src/core/hle/kernel/condition_variable.h b/src/core/hle/kernel/condition_variable.hdeleted file mode 100644index 1c9f067694..0000000000--- a/src/core/hle/kernel/condition_variable.h+++ /dev/null@@ -1,63 +0,0 @@-// Copyright 2018 yuzu emulator team-// Licensed under GPLv2 or any later version-// Refer to the license.txt file included.--#pragma once--#include <string>-#include <queue>-#include "common/common_types.h"-#include "core/hle/kernel/kernel.h"-#include "core/hle/kernel/wait_object.h"-#include "core/hle/result.h"--namespace Kernel {--class ConditionVariable final : public WaitObject {-public:- /**- * Creates a condition variable.- * @param guest_addr Address of the object tracking the condition variable in guest memory. If- * specified, this condition variable will update the guest object when its state changes.- * @param name Optional name of condition variable.- * @return The created condition variable.- */- static ResultVal<SharedPtr<ConditionVariable>> Create(VAddr guest_addr,- std::string name = "Unknown");-- std::string GetTypeName() const override {- return "ConditionVariable";- }- std::string GetName() const override {- return name;- }-- static const HandleType HANDLE_TYPE = HandleType::ConditionVariable;- HandleType GetHandleType() const override {- return HANDLE_TYPE;- }-- s32 GetAvailableCount() const;- void SetAvailableCount(s32 value) const;-- std::string name; ///< Name of condition variable (optional)- VAddr guest_addr; ///< Address of the guest condition variable value- VAddr mutex_addr; ///< (optional) Address of guest mutex value associated with this condition- ///< variable, used for implementing events-- bool ShouldWait(Thread* thread) const override;- void Acquire(Thread* thread) override;-- /**- * Releases a slot from a condition variable.- * @param target The number of threads to wakeup, -1 is all.- * @return ResultCode indicating if the operation succeeded.- */- ResultCode Release(s32 target);--private:- ConditionVariable();- ~ConditionVariable() override;-};--} // namespace Kerneldiff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cppindex 99c1c2d2a1..082c36cafd 100644--- a/src/core/hle/kernel/svc.cpp+++ b/src/core/hle/kernel/svc.cpp@@ -13,7 +13,6 @@#include "core/core_timing.h"#include "core/hle/kernel/client_port.h"#include "core/hle/kernel/client_session.h"-#include "core/hle/kernel/condition_variable.h"#include "core/hle/kernel/event.h"#include "core/hle/kernel/handle_table.h"#include "core/hle/kernel/mutex.h"@@ -394,11 +393,6 @@ static ResultCode SetThreadPriority(Handle handle, u32 priority) {}thread->SetPriority(priority);- thread->UpdatePriority();-- // Update the mutexes that this thread is waiting for- for (auto& mutex : thread->pending_mutexes)- mutex->UpdatePriority();Core::System::GetInstance().PrepareReschedule();return RESULT_SUCCESS;diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cppindex 8093c44960..16d9b9e365 100644--- a/src/core/hle/kernel/thread.cpp+++ b/src/core/hle/kernel/thread.cpp@@ -329,15 +329,6 @@ void Thread::SetPriority(u32 priority) {nominal_priority = current_priority = priority;}-void Thread::UpdatePriority() {- u32 best_priority = nominal_priority;- for (auto& mutex : held_mutexes) {- if (mutex->priority < best_priority)- best_priority = mutex->priority;- }- BoostPriority(best_priority);-}-void Thread::BoostPriority(u32 priority) {Core::System::GetInstance().Scheduler().SetThreadPriority(this, priority);current_priority = priority;diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.hindex 74d5904b8f..ee13d20f1a 100644--- a/src/core/hle/kernel/thread.h+++ b/src/core/hle/kernel/thread.h@@ -103,12 +103,6 @@ public:*/void SetPriority(u32 priority);- /**- * Boost's a thread's priority to the best priority among the thread's held mutexes.- * This prevents priority inversion via priority inheritance.- */- void UpdatePriority();-/*** Temporarily boosts the thread's priority until the next time it is scheduled* @param priority The new priority