Solved QMutex and unique_lock ?
-
I'm replacing mutex references in a project previously using boost for:
boost::mutex and boost::recursive_mutex
There are also several instances using:
std::unique_lock<boost::mutex> lock(&mutex);
https://en.cppreference.com/w/cpp/thread/unique_lock
Is there an equivalent implementation for achieving the same using a QMutex ?
-
-
-
@jsulm , I see what there are references to recursive, but no reference to unique anywhere.
-
@SPlatten said in QMutex and unique_lock ?:
I see what there are references to recursive, but no reference to unique anywhere.
Don't get hung up on the name. https://en.cppreference.com/w/cpp/thread/unique_lock has no reference to "unique" anywhere either (except for the name of the class)!
- A
std::unique_lock
is simply astd::lock_guard
that can be unlocked/relocked. - A
QMutexLocker
is like astd::lock_guard
that can be unlocked/relocked.
Just use
QMutexLocker
the same way you'd usestd::unique_lock
. - A
-
@JKSH Thanks