Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
5.15
-
None
-
All multithread could use that.
Description
Would be nice to have the QTryMutexLocker along the QMutexLocker.
Something like this:
class QTryMutexLocker { public: QTryMutexLocker(QMutex &m, int timeout = 0); ~TryMutexLocker(); bool isLocked() const; private: QMutex &m_mutex; bool m_locked; }; QTryMutexLocker::QTryMutexLocker(QMutex &m, int timeout) : m_mutex(m) , m_locked(m.tryLock(timeout)) { } QTryMutexLocker::~QTryMutexLocker() { if(m_locked) m_mutex.unlock(); } bool QTryMutexLocker::isLocked() const { return m_locked; }