revert can_unlock flag

This commit is contained in:
2026-03-18 08:54:06 +03:00
parent 9dc1af921c
commit ac415ebbb6

View File

@@ -49,11 +49,15 @@ public:
public:
//! \~english Move constructor - transfers ownership of the lock.
//! \~russian Конструктор перемещения - передает владение блокировкой.
Pointer(Pointer && other): pv(other.pv) { pv.mutex.lock(); };
Pointer(Pointer && other): pv(other.pv) { other.can_unlock = false; };
//! \~english Destroys wrapper and releases the mutex.
//! \~russian Уничтожает обертку и освобождает мьютекс.
~Pointer() { pv.mutex.unlock(); }
~Pointer() {
if (can_unlock) {
pv.mutex.unlock();
}
}
//! \~english Returns pointer access to the protected value.
//! \~russian Возвращает указательный доступ к защищенному значению.
@@ -68,6 +72,7 @@ public:
explicit Pointer(PIProtectedVariable<T> & v): pv(v) { pv.mutex.lock(); }
PIProtectedVariable<T> & pv;
bool can_unlock = true;
};
//! \~english Replaces the protected value with \a v.