summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-17 10:19:31 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-17 10:34:24 +0200
commitd0a0a3c0418a0fdd2ed84b2a5f7e6565537715c6 (patch)
treed6aeb4d51caf30ccf23eadb806a09295cbf679cd /src/corelib/thread
parent9f405f98a4247cd263b9c5d35659a4ba89e282de (diff)
parentac35f9c44c0fb3b2f40ae5585c497200b2ba743d (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: examples/network/fortuneclient/client.cpp examples/network/fortuneserver/server.cpp src/platformsupport/platformcompositor/qopenglcompositorbackingstore_p.h src/plugins/platforms/cocoa/qcocoabackingstore.h src/plugins/platforms/cocoa/qcocoaintegration.h src/plugins/platforms/cocoa/qcocoascreen.h src/plugins/platforms/ios/qiosbackingstore.h src/plugins/sqldrivers/oci/qsql_oci.cpp src/widgets/kernel/qwidgetwindow.cpp Change-Id: Ia6dd2c52d4a691b671cf9a2ffca70deccece8f10
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.cpp4
-rw-r--r--src/corelib/thread/qthread.h36
2 files changed, 17 insertions, 23 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index e3ba1e4449..e92be64dfa 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -925,7 +925,7 @@ bool QThread::isInterruptionRequested() const
\sa start()
*/
-#ifdef QTHREAD_HAS_CREATE
+#if QT_CONFIG(cxx11_future)
class QThreadCreateThread : public QThread
{
public:
@@ -947,7 +947,7 @@ QThread *QThread::createThreadImpl(std::future<void> &&future)
{
return new QThreadCreateThread(std::move(future));
}
-#endif // QTHREAD_HAS_CREATE
+#endif // QT_CONFIG(cxx11_future)
/*!
\class QDaemonThread
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index d18152a52d..1f98cb59af 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -42,17 +43,10 @@
#include <QtCore/qobject.h>
-// The implementation of QThread::create uses various C++14/C++17 facilities;
-// we must check for their presence. Specifically for glibcxx bundled in MinGW
-// with win32 threads, we check the condition found in its <future> header
-// since _GLIBCXX_HAS_GTHREADS might then not be defined.
-// For std::async (used in all codepaths)
-// there is no SG10 feature macro; just test for the header presence.
-// For the C++17 codepath do some more throughout checks for std::invoke and
-// C++14 lambdas availability.
-#if QT_HAS_INCLUDE(<future>) \
- && (!defined(__GLIBCXX__) || (defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)))
-# define QTHREAD_HAS_CREATE
+// For QThread::create. The configure-time test just checks for the availability
+// of std::future and std::async; for the C++17 codepath we perform some extra
+// checks here (for std::invoke and C++14 lambdas).
+#if QT_CONFIG(cxx11_future)
# include <future> // for std::async
# include <functional> // for std::invoke; no guard needed as it's a C++98 header
@@ -125,16 +119,16 @@ public:
template <typename Function>
static QThread *create(Function &&f);
#else
-#ifdef QTHREAD_HAS_CREATE
-#ifdef QTHREAD_HAS_VARIADIC_CREATE
+# if QT_CONFIG(cxx11_future)
+# ifdef QTHREAD_HAS_VARIADIC_CREATE
template <typename Function, typename... Args>
static QThread *create(Function &&f, Args &&... args);
-#else
+# else
template <typename Function>
static QThread *create(Function &&f);
-#endif
-#endif
-#endif
+# endif // QTHREAD_HAS_VARIADIC_CREATE
+# endif // QT_CONFIG(cxx11_future)
+#endif // Q_QDOC
public Q_SLOTS:
void start(Priority = InheritPriority);
@@ -165,7 +159,7 @@ protected:
private:
Q_DECLARE_PRIVATE(QThread)
-#ifdef QTHREAD_HAS_CREATE
+#if QT_CONFIG(cxx11_future)
static QThread *createThreadImpl(std::future<void> &&future);
#endif
@@ -173,9 +167,9 @@ private:
friend class QThreadData;
};
-#ifdef QTHREAD_HAS_CREATE
+#if QT_CONFIG(cxx11_future)
-#ifdef QTHREAD_HAS_VARIADIC_CREATE
+#if defined(QTHREAD_HAS_VARIADIC_CREATE)
// C++17: std::thread's constructor complying call
template <typename Function, typename... Args>
QThread *QThread::create(Function &&f, Args &&... args)
@@ -243,7 +237,7 @@ QThread *QThread::create(Function &&f)
}
#endif // QTHREAD_HAS_VARIADIC_CREATE
-#endif // QTHREAD_HAS_CREATE
+#endif // QT_CONFIG(cxx11_future)
#else // QT_NO_THREAD