diff --git a/libs/main/thread/piprotectedvariable.h b/libs/main/thread/piprotectedvariable.h index 650d79f5..754eb4e3 100644 --- a/libs/main/thread/piprotectedvariable.h +++ b/libs/main/thread/piprotectedvariable.h @@ -25,7 +25,6 @@ #ifndef PIPROTECTEDVARIABLE_H #define PIPROTECTEDVARIABLE_H -#include "picout.h" #include "pimutex.h" //! \~\ingroup Thread @@ -35,6 +34,8 @@ template class PIP_EXPORT PIProtectedVariable { public: + //! \~english Constructs %PIProtectedVariable and initialize variable by value `v`. + //! \~russian Создает %PIProtectedVariable и инициализирует переменную значением `v`. PIProtectedVariable(T v = T()): var(std::move(v)) {} //! \~\brief @@ -43,26 +44,18 @@ public: class PIP_EXPORT Pointer { friend class PIProtectedVariable; NO_COPY_CLASS(Pointer); + Pointer & operator=(Pointer && other) = delete; public: - //! \~\english Move constructor - transfers ownership of the lock. + //! \~english Move constructor - transfers ownership of the lock. //! \~russian Конструктор перемещения - передает владение блокировкой. Pointer(Pointer && other): pv(other.pv) { other.can_unlock = false; }; - - //! \~\english Move assignment - transfers ownership of the lock. - //! \~russian Оператор перемещения - передает владение блокировкой. - Pointer & operator=(Pointer && other) { - pv = other.pv; - other.can_unlock = false; - }; - - //! \~\english Destroys wrapper and releases the mutex. + //! \~english Destroys wrapper and releases the mutex. //! \~russian Уничтожает обертку и освобождает мьютекс. ~Pointer() { if (can_unlock) { pv.mutex.unlock(); - piCout << "mutex.unlock()" << &(pv.mutex); } } @@ -76,10 +69,7 @@ public: private: explicit Pointer() = delete; - explicit Pointer(PIProtectedVariable & v): pv(v) { - pv.mutex.lock(); - piCout << "mutex.lock()" << &(pv.mutex); - } + explicit Pointer(PIProtectedVariable & v): pv(v) { pv.mutex.lock(); } PIProtectedVariable & pv; bool can_unlock = true; diff --git a/main.cpp b/main.cpp index fd98c891..7dda6513 100644 --- a/main.cpp +++ b/main.cpp @@ -23,9 +23,9 @@ int main(int argc, char * argv[]) { PIProtectedVariable pv(3.0); piCout << pv.get(); { - auto ref = pv.getRef(); + auto ref = pv.getRef(); piCout << *ref; - *ref = 11.; + *ref = 11.; piCout << *ref; } piCout << pv.get();