remove picout

This commit is contained in:
2026-03-17 18:34:48 +03:00
parent ac877f1024
commit 9f57f0107e
2 changed files with 8 additions and 18 deletions

View File

@@ -25,7 +25,6 @@
#ifndef PIPROTECTEDVARIABLE_H
#define PIPROTECTEDVARIABLE_H
#include "picout.h"
#include "pimutex.h"
//! \~\ingroup Thread
@@ -35,6 +34,8 @@
template<typename T>
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<T>;
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<T> & v): pv(v) {
pv.mutex.lock();
piCout << "mutex.lock()" << &(pv.mutex);
}
explicit Pointer(PIProtectedVariable<T> & v): pv(v) { pv.mutex.lock(); }
PIProtectedVariable<T> & pv;
bool can_unlock = true;

View File

@@ -23,9 +23,9 @@ int main(int argc, char * argv[]) {
PIProtectedVariable<double> 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();