QtTest: fix build with MinGW/GCC 9: no std::mutex support
Unfortunately we can't depend on the C++11, 14 or 17 Standard
Library, which is not properly and completely implemented
everywhere. All Library features above C++98 must be checked with
their corresponding __cpp_lib macro before use. This does not
apply to the C++17 Core Language.
qwaitcondition_p.h:144:20: error: 'mutex' in namespace 'std' does not name a type
144 | using mutex = std::mutex;
| ^~~~~
qwaitcondition_p.h:59:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
58 | #include <condition_variable>
+++ |+#include <mutex>
59 | #include <mutex>
qwaitcondition_p.h:145:33: error: 'condition_variable' in namespace 'std' does not name a type
145 | using condition_variable = std::condition_variable;
| ^~~~~~~~~~~~~~~~~~
qwaitcondition_p.h:59:1: note: 'std::condition_variable' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
58 | #include <condition_variable>
+++ |+#include <condition_variable>
59 | #include <mutex>
Pick-to: 6.2
Change-Id: I2bbf422288924c198645fffd16a9249e5330136a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
parent
e0b6b27d39
commit
1bac82fa99
|
|
@ -58,12 +58,20 @@
|
|||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
// There's no feature macro for C++11 std::mutex, so we use the C++14 one
|
||||
// for shared_mutex to detect it.
|
||||
// Needed for: MinGW without gthreads, Integrity
|
||||
#if __has_include(<shared_mutex>)
|
||||
# include <shared_mutex>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QtPrivate {
|
||||
|
||||
#if defined(Q_OS_INTEGRITY)
|
||||
#if !defined(__cpp_lib_shared_timed_mutex)
|
||||
|
||||
enum class cv_status { no_timeout, timeout };
|
||||
class condition_variable;
|
||||
|
||||
class mutex : private QMutex
|
||||
|
|
@ -97,12 +105,12 @@ public:
|
|||
}
|
||||
|
||||
template <typename Rep, typename Period>
|
||||
std::cv_status wait_for(std::unique_lock<QtPrivate::mutex> &lock,
|
||||
cv_status wait_for(std::unique_lock<QtPrivate::mutex> &lock,
|
||||
const std::chrono::duration<Rep, Period> &d)
|
||||
{
|
||||
return QWaitCondition::wait(lock.mutex(), QDeadlineTimer{d})
|
||||
? std::cv_status::no_timeout
|
||||
: std::cv_status::timeout;
|
||||
? cv_status::no_timeout
|
||||
: cv_status::timeout;
|
||||
}
|
||||
template <typename Rep, typename Period, typename Predicate>
|
||||
bool wait_for(std::unique_lock<QtPrivate::mutex> &lock,
|
||||
|
|
@ -117,12 +125,12 @@ public:
|
|||
}
|
||||
|
||||
template <typename Clock, typename Duration>
|
||||
std::cv_status wait_until(std::unique_lock<QtPrivate::mutex> &lock,
|
||||
cv_status wait_until(std::unique_lock<QtPrivate::mutex> &lock,
|
||||
const std::chrono::time_point<Clock, Duration> &t)
|
||||
{
|
||||
return QWaitCondition::wait(lock.mutex(), QDeadlineTimer{t})
|
||||
? std::cv_status::no_timeout
|
||||
: std::cv_status::timeout;
|
||||
? cv_status::no_timeout
|
||||
: cv_status::timeout;
|
||||
}
|
||||
|
||||
template <typename Clock, typename Duration, typename Predicate>
|
||||
|
|
@ -139,12 +147,12 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#else // Integrity
|
||||
#else // C++11 threads
|
||||
|
||||
using mutex = std::mutex;
|
||||
using condition_variable = std::condition_variable;
|
||||
|
||||
#endif // Integrity
|
||||
#endif // C++11 threads
|
||||
|
||||
} // namespace QtPrivate
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue