diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/kernel/k_scoped_lock.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index 59b3e32ae..629a7d20d 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h @@ -4,6 +4,7 @@ #pragma once #include <concepts> +#include <memory> #include <type_traits> namespace Kernel { @@ -17,15 +18,15 @@ std::is_reference_v<T>&& requires(T& t) { template <typename T> requires KLockable<T> -class [[nodiscard]] KScopedLock { +class KScopedLock { public: - explicit KScopedLock(T* l) : lock_ptr(l) { - this->lock_ptr->Lock(); + explicit KScopedLock(T* l) : m_lock(*l) {} + explicit KScopedLock(T& l) : m_lock(l) { + m_lock.Lock(); } - explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {} ~KScopedLock() { - this->lock_ptr->Unlock(); + m_lock.Unlock(); } KScopedLock(const KScopedLock&) = delete; @@ -35,7 +36,7 @@ public: KScopedLock& operator=(KScopedLock&&) = delete; private: - T* lock_ptr; + T& m_lock; }; } // namespace Kernel |