PIMutex as std::mutex
This commit is contained in:
@@ -25,42 +25,42 @@
|
||||
|
||||
#include "piinit.h"
|
||||
|
||||
class PIP_EXPORT PIMutex
|
||||
{
|
||||
public:
|
||||
//! Constructs unlocked mutex
|
||||
explicit PIMutex();
|
||||
|
||||
//class PIP_EXPORT PIMutex
|
||||
//{
|
||||
//public:
|
||||
// //! Constructs unlocked mutex
|
||||
// explicit PIMutex();
|
||||
|
||||
//! Destroy mutex
|
||||
~PIMutex();
|
||||
// //! Destroy mutex
|
||||
// ~PIMutex();
|
||||
|
||||
|
||||
//! \brief Lock mutex
|
||||
//! \details If mutex is unlocked it set to locked state and returns immediate.
|
||||
//! If mutex is already locked function blocks until mutex will be unlocked
|
||||
void lock();
|
||||
// //! \brief Lock mutex
|
||||
// //! \details If mutex is unlocked it set to locked state and returns immediate.
|
||||
// //! If mutex is already locked function blocks until mutex will be unlocked
|
||||
// void lock();
|
||||
|
||||
//! \brief Unlock mutex
|
||||
//! \details In any case this function returns immediate
|
||||
void unlock();
|
||||
// //! \brief Unlock mutex
|
||||
// //! \details In any case this function returns immediate
|
||||
// void unlock();
|
||||
|
||||
//! \brief Try to lock mutex
|
||||
//! \details If mutex is unlocked it set to locked state and returns "true" immediate.
|
||||
//! If mutex is already locked function returns immediate an returns "false"
|
||||
bool tryLock();
|
||||
// //! \brief Try to lock mutex
|
||||
// //! \details If mutex is unlocked it set to locked state and returns "true" immediate.
|
||||
// //! If mutex is already locked function returns immediate an returns "false"
|
||||
// bool tryLock();
|
||||
|
||||
//! Returns if mutex is locked
|
||||
bool isLocked() const;
|
||||
// //! Returns if mutex is locked
|
||||
// bool isLocked() const;
|
||||
|
||||
private:
|
||||
NO_COPY_CLASS(PIMutex)
|
||||
//private:
|
||||
// NO_COPY_CLASS(PIMutex)
|
||||
|
||||
void init();
|
||||
void destroy();
|
||||
bool inited_;
|
||||
bool locked;
|
||||
PRIVATE_DECLARATION
|
||||
};
|
||||
// void init();
|
||||
// void destroy();
|
||||
// bool inited_;
|
||||
// PRIVATE_DECLARATION
|
||||
//};
|
||||
|
||||
|
||||
class PIP_EXPORT PIMutexLocker
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
~PIMutexLocker() {if (cond) mutex->unlock();}
|
||||
private:
|
||||
PIMutex * mutex;
|
||||
volatile bool cond;
|
||||
std::atomic_bool cond;
|
||||
};
|
||||
|
||||
#endif // PIMUTEX_H
|
||||
|
||||
Reference in New Issue
Block a user