remove picout
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user