diff options
author | bunnei <bunneidev@gmail.com> | 2021-04-10 06:42:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-10 06:42:26 +0200 |
commit | c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c (patch) | |
tree | 05326414c56f7f5d4c4d98b688119bfacee5d0c9 /src | |
parent | Merge pull request #6113 from german77/playhistory (diff) | |
parent | Amend bizarre clang-format suggestions (diff) | |
download | yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.tar yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.tar.gz yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.tar.bz2 yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.tar.lz yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.tar.xz yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.tar.zst yuzu-c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/kernel/k_scheduler.h | 4 | ||||
-rw-r--r-- | src/core/hle/kernel/k_scoped_lock.h | 13 | ||||
-rw-r--r-- | src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/core/hle/kernel/k_scheduler.h b/src/core/hle/kernel/k_scheduler.h index f595b9a5c..70d6bfcee 100644 --- a/src/core/hle/kernel/k_scheduler.h +++ b/src/core/hle/kernel/k_scheduler.h @@ -198,9 +198,9 @@ private: Common::SpinLock guard{}; }; -class KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> { +class [[nodiscard]] KScopedSchedulerLock : KScopedLock<GlobalSchedulerContext::LockType> { public: - explicit KScopedSchedulerLock(KernelCore& kernel); + explicit KScopedSchedulerLock(KernelCore & kernel); ~KScopedSchedulerLock(); }; diff --git a/src/core/hle/kernel/k_scoped_lock.h b/src/core/hle/kernel/k_scoped_lock.h index d7cc557b2..72c3b0252 100644 --- a/src/core/hle/kernel/k_scoped_lock.h +++ b/src/core/hle/kernel/k_scoped_lock.h @@ -20,19 +20,22 @@ concept KLockable = !std::is_reference_v<T> && requires(T & t) { }; template <typename T> -requires KLockable<T> class KScopedLock { +requires KLockable<T> class [[nodiscard]] KScopedLock { public: - explicit KScopedLock(T* l) : lock_ptr(l) { + explicit KScopedLock(T * l) : lock_ptr(l) { this->lock_ptr->Lock(); } - explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) { /* ... */ - } + explicit KScopedLock(T & l) : KScopedLock(std::addressof(l)) {} + ~KScopedLock() { this->lock_ptr->Unlock(); } KScopedLock(const KScopedLock&) = delete; - KScopedLock(KScopedLock&&) = delete; + KScopedLock& operator=(const KScopedLock&) = delete; + + KScopedLock(KScopedLock &&) = delete; + KScopedLock& operator=(KScopedLock&&) = delete; private: T* lock_ptr; diff --git a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h index f8189e107..ebecf0c77 100644 --- a/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h +++ b/src/core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h @@ -15,9 +15,9 @@ namespace Kernel { -class KScopedSchedulerLockAndSleep { +class [[nodiscard]] KScopedSchedulerLockAndSleep { public: - explicit KScopedSchedulerLockAndSleep(KernelCore& kernel, KThread* t, s64 timeout) + explicit KScopedSchedulerLockAndSleep(KernelCore & kernel, KThread * t, s64 timeout) : kernel(kernel), thread(t), timeout_tick(timeout) { // Lock the scheduler. kernel.GlobalSchedulerContext().scheduler_lock.Lock(); |