|
|
@ -22,10 +22,10 @@ concept KLockable = !std::is_reference_v<T> && requires(T & t) {
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
requires KLockable<T> class [[nodiscard]] KScopedLock {
|
|
|
|
requires KLockable<T> class [[nodiscard]] KScopedLock {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
explicit KScopedLock(T* l) : lock_ptr(l) {
|
|
|
|
explicit KScopedLock(T * l) : lock_ptr(l) {
|
|
|
|
this->lock_ptr->Lock();
|
|
|
|
this->lock_ptr->Lock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
explicit KScopedLock(T& l) : KScopedLock(std::addressof(l)) {}
|
|
|
|
explicit KScopedLock(T & l) : KScopedLock(std::addressof(l)) {}
|
|
|
|
|
|
|
|
|
|
|
|
~KScopedLock() {
|
|
|
|
~KScopedLock() {
|
|
|
|
this->lock_ptr->Unlock();
|
|
|
|
this->lock_ptr->Unlock();
|
|
|
@ -34,7 +34,7 @@ public:
|
|
|
|
KScopedLock(const KScopedLock&) = delete;
|
|
|
|
KScopedLock(const KScopedLock&) = delete;
|
|
|
|
KScopedLock& operator=(const KScopedLock&) = delete;
|
|
|
|
KScopedLock& operator=(const KScopedLock&) = delete;
|
|
|
|
|
|
|
|
|
|
|
|
KScopedLock(KScopedLock&&) = delete;
|
|
|
|
KScopedLock(KScopedLock &&) = delete;
|
|
|
|
KScopedLock& operator=(KScopedLock&&) = delete;
|
|
|
|
KScopedLock& operator=(KScopedLock&&) = delete;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|