1 #ifndef THREADING_UTILS_TRYLOCKER_H 2 #define THREADING_UTILS_TRYLOCKER_H 6 QT_FORWARD_DECLARE_CLASS(QMutex)
13 template <
typename Mutex = QMutex>
class TryLocker {
19 : m_mutex(mutex.tryLock() ? &mutex : nullptr)
39 return m_mutex !=
nullptr;
47 return m_mutex !=
nullptr;
55 #endif // THREADING_UTILS_TRYLOCKER_H bool isLocked() const
Returns whether the mutex could be locked.
Like QMutexLocker, but it just tries to lock the mutex.
TryLocker(Mutex &mutex)
Tries to lock the specified mutex.
~TryLocker()
Unlocks the mutex specified when constructing.