diff options
| author | bunnei <bunneidev@gmail.com> | 2021-04-09 21:42:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-09 21:42:26 -0700 |
| commit | c6d2af16b50fe30baa8e3c13b4fa5f9ef242096c (patch) | |
| tree | 05326414c56f7f5d4c4d98b688119bfacee5d0c9 /src/core/hle/kernel/k_scoped_lock.h | |
| parent | 9cf8bcc75c4fe29c514bc32315bcd79d5522b596 (diff) | |
| parent | 530a5a1d099805c5fc2cfa1a31229c3f8e7dd019 (diff) | |
Merge pull request #6156 from lioncash/lock-discard
kernel: Mark lock helper classes as [[nodiscard]]
Diffstat (limited to 'src/core/hle/kernel/k_scoped_lock.h')
| -rw-r--r-- | src/core/hle/kernel/k_scoped_lock.h | 13 |
1 files changed, 8 insertions, 5 deletions
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; |
