From e761625eab90641cdfee280528665322d481f1c4 Mon Sep 17 00:00:00 2001 From: "andrey.bychkov" Date: Tue, 17 Mar 2026 19:14:14 +0300 Subject: [PATCH] using recursive mutex --- libs/main/thread/piprotectedvariable.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libs/main/thread/piprotectedvariable.h b/libs/main/thread/piprotectedvariable.h index 754eb4e3..077d2192 100644 --- a/libs/main/thread/piprotectedvariable.h +++ b/libs/main/thread/piprotectedvariable.h @@ -49,15 +49,11 @@ public: public: //! \~english Move constructor - transfers ownership of the lock. //! \~russian Конструктор перемещения - передает владение блокировкой. - Pointer(Pointer && other): pv(other.pv) { other.can_unlock = false; }; + Pointer(Pointer && other): pv(other.pv) { pv.mutex.lock(); }; //! \~english Destroys wrapper and releases the mutex. //! \~russian Уничтожает обертку и освобождает мьютекс. - ~Pointer() { - if (can_unlock) { - pv.mutex.unlock(); - } - } + ~Pointer() { pv.mutex.unlock(); } //! \~english Returns pointer access to the protected value. //! \~russian Возвращает указательный доступ к защищенному значению. @@ -72,7 +68,6 @@ public: explicit Pointer(PIProtectedVariable & v): pv(v) { pv.mutex.lock(); } PIProtectedVariable & pv; - bool can_unlock = true; }; //! \~english Replaces the protected value with \a v.