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;
Like QMutexLocker, but it just tries to lock the mutex.
bool isLocked() const
Returns whether the mutex could be locked.
~TryLocker()
Unlocks the mutex specified when constructing.
TryLocker(Mutex &mutex)
Tries to lock the specified mutex.