diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-12-29 17:11:24 +0100 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2018-08-17 00:34:36 +0000 |
commit | 0a06e1baf9e6da5308582b9dc928f4d9fea508d0 (patch) | |
tree | 187be725390515db55f56e5f2cdebad60ee183f8 /src/corelib | |
parent | 815153d4a453855bb528f0fa9cb7e5a77d589a11 (diff) |
Modernize the "thread" feature
Add it to configure.json and replace all occurrences of QT_NO_THREAD
with QT_CONFIG(thread). Add conditions for other features that depend
on thread support. Remove conditions where we can use the QMutex and
QThreadStorage stubs.
Change-Id: I284e5d794fda9a4c6f4a1ab29e55aa686272a0eb
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/corelib')
41 files changed, 135 insertions, 198 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index b3db200ed1..48983def79 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -215,9 +215,7 @@ typedef QList<QAbstractAnimation*>::ConstIterator AnimationListConstIt; QUnifiedTimer drives animations indirectly, via QAbstractAnimationTimer. */ -#ifndef QT_NO_THREAD Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) -#endif QUnifiedTimer::QUnifiedTimer() : QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), @@ -234,18 +232,12 @@ QUnifiedTimer::QUnifiedTimer() : QUnifiedTimer *QUnifiedTimer::instance(bool create) { QUnifiedTimer *inst; -#ifndef QT_NO_THREAD if (create && !unifiedTimer()->hasLocalData()) { inst = new QUnifiedTimer; unifiedTimer()->setLocalData(inst); } else { inst = unifiedTimer() ? unifiedTimer()->localData() : 0; } -#else - Q_UNUSED(create); - static QUnifiedTimer unifiedTimer; - inst = &unifiedTimer; -#endif return inst; } @@ -554,7 +546,7 @@ bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d) return d == driver && driver != &defaultDriver; } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) Q_GLOBAL_STATIC(QThreadStorage<QAnimationTimer *>, animationTimer) #endif @@ -569,7 +561,7 @@ QAnimationTimer::QAnimationTimer() : QAnimationTimer *QAnimationTimer::instance(bool create) { QAnimationTimer *inst; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (create && !animationTimer()->hasLocalData()) { inst = new QAnimationTimer; animationTimer()->setLocalData(inst); diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index b8b064d43b..a8dbb3edcd 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -115,7 +115,7 @@ #define QT_NO_SYSTEMLOCALE #define QT_FEATURE_systemsemaphore -1 #define QT_FEATURE_temporaryfile 1 -#define QT_NO_THREAD +#define QT_FEATURE_thread -1 #define QT_FEATURE_timezone -1 #define QT_FEATURE_topleveldomain -1 #define QT_NO_TRANSLATION diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 37cc40f577..a369bbe490 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -53,10 +53,6 @@ #include <qmutex.h> -#ifndef QT_NO_QOBJECT -#include <private/qthread_p.h> -#endif - #include <stdlib.h> #include <limits.h> #include <stdarg.h> diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h index 7a6dea9b92..555bdf04c1 100644 --- a/src/corelib/global/qglobalstatic.h +++ b/src/corelib/global/qglobalstatic.h @@ -55,7 +55,7 @@ enum GuardValues { }; } -#if defined(QT_NO_THREAD) || defined(Q_COMPILER_THREADSAFE_STATICS) +#if !QT_CONFIG(thread) || defined(Q_COMPILER_THREADSAFE_STATICS) // some compilers support thread-safe statics // The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4 // support it. C++11 also requires this behavior. diff --git a/src/corelib/global/qglobalstatic.qdoc b/src/corelib/global/qglobalstatic.qdoc index 303709bb1d..dbea04ecab 100644 --- a/src/corelib/global/qglobalstatic.qdoc +++ b/src/corelib/global/qglobalstatic.qdoc @@ -264,7 +264,7 @@ [stmt.decl], but as of the time of this writing, only compilers based on the IA-64 C++ ABI implemented it properly. The implementation requiring thread-safe initialization is also used on the Qt bootstrapped tools, which - define QT_NO_THREAD. + disable the "thread" feature. The implementation requiring thread-safe initialization from the compiler is the simplest: it creates the \a Type object as a function-local static diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 66deac2a29..a7d4aa303a 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -1298,7 +1298,7 @@ struct QRandEngine }; } -#if defined(QT_NO_THREAD) || defined(Q_OS_WIN) +#if defined(Q_OS_WIN) // On Windows srand() and rand() already use Thread-Local-Storage // to store the seed between calls static inline QRandEngine *randTLS() diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index d0cd5449f0..835e6a6a44 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -853,7 +853,7 @@ QByteArray QFileSystemEngine::id(int id) //static QString QFileSystemEngine::resolveUserName(uint userId) { -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); if (size_max == -1) size_max = 1024; @@ -862,7 +862,7 @@ QString QFileSystemEngine::resolveUserName(uint userId) #if !defined(Q_OS_INTEGRITY) struct passwd *pw = 0; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) struct passwd entry; getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw); #else @@ -877,7 +877,7 @@ QString QFileSystemEngine::resolveUserName(uint userId) //static QString QFileSystemEngine::resolveGroupName(uint groupId) { -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); if (size_max == -1) size_max = 1024; @@ -886,7 +886,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) #if !defined(Q_OS_INTEGRITY) struct group *gr = 0; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24)) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_VXWORKS) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID) && (__ANDROID_API__ >= 24)) size_max = sysconf(_SC_GETGR_R_SIZE_MAX); if (size_max == -1) size_max = 1024; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 93cfd93d7e..9d3bfbba31 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -45,7 +45,6 @@ #include "qfile.h" #include "qdir.h" -#include "private/qmutexpool_p.h" #include "qvarlengtharray.h" #include "qdatetime.h" #include "qt_windows.h" diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 713af9bd40..7a2daa2a57 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -101,7 +101,6 @@ QT_END_NAMESPACE #include <qdir.h> #include <qlist.h> #include <qmutex.h> -#include <qsemaphore.h> #include <qsocketnotifier.h> #include <qthread.h> #include <qelapsedtimer.h> diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index b5df0db232..58380001a4 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -42,6 +42,7 @@ #include "qhash.h" #include "qpair.h" +#include "qmutex.h" #include "qvarlengtharray.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index aea8fe6658..04da52a960 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -58,9 +58,11 @@ #include <qtextcodec.h> #ifndef QT_NO_QOBJECT #include <qthread.h> -#include <qthreadpool.h> #include <qthreadstorage.h> #include <private/qthread_p.h> +#if QT_CONFIG(thread) +#include <qthreadpool.h> +#endif #endif #include <qelapsedtimer.h> #include <qlibraryinfo.h> @@ -268,9 +270,7 @@ typedef QList<QtStartUpFunction> QStartUpFuncList; Q_GLOBAL_STATIC(QStartUpFuncList, preRList) typedef QList<QtCleanUpFunction> QVFuncList; Q_GLOBAL_STATIC(QVFuncList, postRList) -#ifndef QT_NO_QOBJECT static QBasicMutex globalRoutinesMutex; -#endif /*! \internal @@ -289,9 +289,7 @@ void qAddPreRoutine(QtStartUpFunction p) // Due to C++11 parallel dynamic initialization, this can be called // from multiple threads. -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines } @@ -300,9 +298,7 @@ void qAddPostRoutine(QtCleanUpFunction p) QVFuncList *list = postRList(); if (!list) return; -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif list->prepend(p); } @@ -311,9 +307,7 @@ void qRemovePostRoutine(QtCleanUpFunction p) QVFuncList *list = postRList(); if (!list) return; -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif list->removeAll(p); } @@ -324,9 +318,7 @@ static void qt_call_pre_routines() QVFuncList list; { -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif // Unlike qt_call_post_routines, we don't empty the list, because // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects // the function to be executed every time QCoreApplication is created. @@ -345,9 +337,7 @@ void Q_CORE_EXPORT qt_call_post_routines() QVFuncList list; { // extract the current list and make the stored list empty -#ifndef QT_NO_THREAD QMutexLocker locker(&globalRoutinesMutex); -#endif qSwap(*postRList, list); } @@ -513,7 +503,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() void QCoreApplicationPrivate::cleanupThreadData() { if (threadData && !threadData_clean) { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void *data = &threadData->tls; QThreadStorageData::finish((void **)data); #endif @@ -888,7 +878,7 @@ QCoreApplication::~QCoreApplication() QCoreApplicationPrivate::is_app_running = false; #endif -#if !defined(QT_NO_THREAD) +#if QT_CONFIG(thread) // Synchronize and stop the global thread pool threads. QThreadPool *globalThreadPool = 0; QT_TRY { diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 65d0bd2351..6c17535f07 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -50,7 +50,9 @@ #include <qthread.h> #include <qvariant.h> #include <qdebug.h> +#if QT_CONFIG(thread) #include <qsemaphore.h> +#endif #include "private/qobject_p.h" #include "private/qmetaobject_p.h" @@ -1540,14 +1542,14 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase * QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 1, types, args)); } else if (type == Qt::BlockingQueuedConnection) { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (currentThread == objectThread) qWarning("QMetaObject::invokeMethod: Dead lock detected"); QSemaphore semaphore; QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 0, 0, argv, &semaphore)); semaphore.acquire(); -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) } else { qWarning("QMetaObject::invokeMethod: Unknown connection type"); return false; @@ -2272,7 +2274,7 @@ bool QMetaMethod::invoke(QObject *object, : Qt::QueuedConnection; } -#ifdef QT_NO_THREAD +#if !QT_CONFIG(thread) if (connectionType == Qt::BlockingQueuedConnection) { connectionType = Qt::DirectConnection; } @@ -2348,7 +2350,7 @@ bool QMetaMethod::invoke(QObject *object, QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction, 0, -1, nargs, types, args)); } else { // blocking queued connection -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (currentThread == objectThread) { qWarning("QMetaMethod::invoke: Dead lock detected in " "BlockingQueuedConnection: Receiver is %s(%p)", @@ -2359,7 +2361,7 @@ bool QMetaMethod::invoke(QObject *object, QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction, 0, -1, 0, 0, param, &semaphore)); semaphore.acquire(); -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) } return true; } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 698ac256ff..6254330d25 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -59,7 +59,9 @@ #include <qpair.h> #include <qvarlengtharray.h> #include <qset.h> +#if QT_CONFIG(thread) #include <qsemaphore.h> +#endif #include <qsharedpointer.h> #include <private/qorderedmutexlocker_p.h> @@ -488,7 +490,7 @@ QMetaCallEvent::~QMetaCallEvent() free(types_); free(args_); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (semaphore_) semaphore_->release(); #endif @@ -3727,7 +3729,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i || (c->connectionType == Qt::QueuedConnection)) { queued_activate(sender, signal_index, c, argv ? argv : empty_argv, locker); continue; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) } else if (c->connectionType == Qt::BlockingQueuedConnection) { if (receiverInSameThread) { qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: " diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index fc825257ec..53c3136857 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ +#if !defined(Q_OS_WIN) && QT_CONFIG(thread) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L namespace { // There are two incompatible versions of strerror_r: @@ -130,7 +130,7 @@ static QString standardLibraryErrorString(int errorCode) s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device"); break; default: { - #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) + #if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) QByteArray buf(1024, Qt::Uninitialized); ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); #else diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 63fb6f3efb..3881ac017e 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -42,8 +42,6 @@ #include "qplatformdefs.h" #include "qmutex.h" #include <qdebug.h> - -#ifndef QT_NO_THREAD #include "qatomic.h" #include "qelapsedtimer.h" #include "qthread.h" @@ -739,5 +737,3 @@ QT_END_NAMESPACE #else # include "qmutex_unix.cpp" #endif - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 7cda53db5f..837355a602 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -54,7 +54,7 @@ class tst_QMutex; QT_BEGIN_NAMESPACE -#if !defined(QT_NO_THREAD) || defined(Q_CLANG_QDOC) +#if QT_CONFIG(thread) || defined(Q_CLANG_QDOC) #ifdef Q_OS_LINUX # define QT_MUTEX_LOCK_NOEXCEPT Q_DECL_NOTHROW @@ -250,7 +250,7 @@ private: quintptr val; }; -#else // QT_NO_THREAD && !Q_CLANG_QDOC +#else // !QT_CONFIG(thread) && !Q_CLANG_QDOC class Q_CORE_EXPORT QMutex { @@ -301,7 +301,7 @@ private: typedef QMutex QBasicMutex; -#endif // QT_NO_THREAD && !Q_CLANG_QDOC +#endif // !QT_CONFIG(thread) && !Q_CLANG_QDOC QT_END_NAMESPACE diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index d3d97ea108..507e72cb76 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -40,8 +40,6 @@ #include "qplatformdefs.h" #include "qmutex.h" - -#ifndef QT_NO_THREAD #include "qatomic.h" #include "qmutex_p.h" #include "qfutex_p.h" @@ -54,7 +52,6 @@ # define FUTEX_PRIVATE_FLAG 0 #endif - QT_BEGIN_NAMESPACE using namespace QtFutex; @@ -183,5 +180,3 @@ void QBasicMutex::unlockInternal() Q_DECL_NOTHROW } QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutex_mac.cpp b/src/corelib/thread/qmutex_mac.cpp index 67498611c9..9a8d9bc750 100644 --- a/src/corelib/thread/qmutex_mac.cpp +++ b/src/corelib/thread/qmutex_mac.cpp @@ -39,9 +39,6 @@ #include "qplatformdefs.h" #include "qmutex.h" - -#if !defined(QT_NO_THREAD) - #include "qmutex_p.h" #include <mach/mach.h> @@ -89,5 +86,3 @@ void QMutexPrivate::wakeUp() Q_DECL_NOTHROW QT_END_NAMESPACE - -#endif //QT_NO_THREAD diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index 91f02ba3ec..3ee24a292c 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -42,8 +42,6 @@ #include "qmutex.h" #include "qstring.h" #include "qelapsedtimer.h" - -#ifndef QT_NO_THREAD #include "qatomic.h" #include "qmutex_p.h" #include <errno.h> @@ -159,5 +157,3 @@ void QMutexPrivate::wakeUp() Q_DECL_NOTHROW #endif QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutexpool.cpp b/src/corelib/thread/qmutexpool.cpp index 90b6989467..3f9e8da942 100644 --- a/src/corelib/thread/qmutexpool.cpp +++ b/src/corelib/thread/qmutexpool.cpp @@ -40,8 +40,6 @@ #include "qatomic.h" #include "qmutexpool_p.h" -#ifndef QT_NO_THREAD - QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC_WITH_ARGS(QMutexPool, globalMutexPool, (QMutex::Recursive)) @@ -148,5 +146,3 @@ QMutex *QMutexPool::globalInstanceGet(const void *address) } QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h index 58d853b0e3..89d006ac29 100644 --- a/src/corelib/thread/qmutexpool_p.h +++ b/src/corelib/thread/qmutexpool_p.h @@ -56,7 +56,7 @@ #include "QtCore/qmutex.h" #include "QtCore/qvarlengtharray.h" -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -85,6 +85,4 @@ private: QT_END_NAMESPACE -#endif // QT_NO_THREAD - #endif // QMUTEXPOOL_P_H diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp index 42befc4b80..21835ff592 100644 --- a/src/corelib/thread/qreadwritelock.cpp +++ b/src/corelib/thread/qreadwritelock.cpp @@ -42,7 +42,6 @@ #include "qplatformdefs.h" #include "qreadwritelock.h" -#ifndef QT_NO_THREAD #include "qmutex.h" #include "qthread.h" #include "qwaitcondition.h" @@ -781,5 +780,3 @@ void QReadWriteLockPrivate::release() */ QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h index ecdb98f2f5..65fa76fd6d 100644 --- a/src/corelib/thread/qreadwritelock.h +++ b/src/corelib/thread/qreadwritelock.h @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class QReadWriteLockPrivate; @@ -174,7 +174,7 @@ inline QWriteLocker::QWriteLocker(QReadWriteLock *areadWriteLock) #pragma warning( pop ) #endif -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class Q_CORE_EXPORT QReadWriteLock { @@ -225,7 +225,7 @@ private: Q_DISABLE_COPY(QWriteLocker) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h index a01d010043..31da2401c0 100644 --- a/src/corelib/thread/qreadwritelock_p.h +++ b/src/corelib/thread/qreadwritelock_p.h @@ -56,7 +56,7 @@ #include <QtCore/qhash.h> #include <QtCore/qwaitcondition.h> -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -99,6 +99,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_THREAD - #endif // QREADWRITELOCK_P_H diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 82d439a728..bb578ff617 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -39,8 +39,6 @@ ****************************************************************************/ #include "qsemaphore.h" - -#ifndef QT_NO_THREAD #include "qmutex.h" #include "qfutex_p.h" #include "qwaitcondition.h" @@ -646,5 +644,3 @@ bool QSemaphore::tryAcquire(int n, int timeout) QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qsemaphore.h b/src/corelib/thread/qsemaphore.h index 2639085e99..b830ff1bfd 100644 --- a/src/corelib/thread/qsemaphore.h +++ b/src/corelib/thread/qsemaphore.h @@ -42,10 +42,9 @@ #include <QtCore/qglobal.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(thread); -#ifndef QT_NO_THREAD +QT_BEGIN_NAMESPACE class QSemaphorePrivate; @@ -113,8 +112,6 @@ private: int m_n; }; -#endif // QT_NO_THREAD - QT_END_NAMESPACE #endif // QSEMAPHORE_H diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index f784bf5cb6..a4101764bc 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -103,7 +103,7 @@ QThreadData::~QThreadData() void QThreadData::ref() { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) (void) _ref.ref(); Q_ASSERT(_ref.load() != 0); #endif @@ -111,7 +111,7 @@ void QThreadData::ref() void QThreadData::deref() { -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) if (!_ref.deref()) delete this; #endif @@ -134,7 +134,7 @@ QAdoptedThread::QAdoptedThread(QThreadData *data) { // thread should be running and not finished for the lifetime // of the application (even if QCoreApplication goes away) -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) d_func()->running = true; d_func()->finished = false; init(); @@ -148,7 +148,7 @@ QAdoptedThread::~QAdoptedThread() // fprintf(stderr, "~QAdoptedThread = %p\n", this); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void QAdoptedThread::run() { // this function should never be called @@ -756,7 +756,7 @@ int QThread::loopLevel() const return d->data->eventLoops.size(); } -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) QThread::QThread(QObject *parent) : QObject(*(new QThreadPrivate), parent) @@ -813,7 +813,7 @@ QThreadPrivate::~QThreadPrivate() delete data; } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) /*! \since 5.0 @@ -850,7 +850,7 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) } } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) /*! \reimp @@ -1015,7 +1015,7 @@ QDaemonThread::~QDaemonThread() { } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 83c3329cc0..d0ffd9f909 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -66,7 +66,7 @@ class QThreadData; class QThreadPrivate; class QAbstractEventDispatcher; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class Q_CORE_EXPORT QThread : public QObject { Q_OBJECT @@ -239,7 +239,7 @@ QThread *QThread::create(Function &&f) #endif // QT_CONFIG(cxx11_future) -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class Q_CORE_EXPORT QThread : public QObject { @@ -267,7 +267,7 @@ private: Q_DECLARE_PRIVATE(QThread) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 93f245ff6e..22a0669032 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -57,7 +57,9 @@ #include "QtCore/qthread.h" #include "QtCore/qmutex.h" #include "QtCore/qstack.h" +#if QT_CONFIG(thread) #include "QtCore/qwaitcondition.h" +#endif #include "QtCore/qmap.h" #include "QtCore/qcoreapplication.h" #include "private/qobject_p.h" @@ -141,7 +143,7 @@ private: using QVector<QPostEvent>::insert; }; -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class Q_CORE_EXPORT QDaemonThread : public QThread { @@ -210,7 +212,7 @@ public: } }; -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class QThreadPrivate : public QObjectPrivate { @@ -231,7 +233,7 @@ public: Q_DECLARE_PUBLIC(QThread) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) class QThreadData { @@ -327,7 +329,7 @@ public: void init(); private: -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void run() override; #endif }; diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 0b3c7ddf10..329caa02ba 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE)); @@ -270,7 +270,7 @@ extern "C" { typedef void*(*QtThreadCallback)(void*); } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data) { @@ -295,7 +295,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat #endif } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) #if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX)) static void setCurrentThreadName(const char *name) @@ -513,7 +513,7 @@ void QThread::yieldCurrentThread() sched_yield(); } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) static timespec makeTimespec(time_t secs, long nsecs) { @@ -538,7 +538,7 @@ void QThread::usleep(unsigned long usecs) qt_nanosleep(makeTimespec(usecs / 1000 / 1000, usecs % (1000*1000) * 1000)); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) #ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING #if defined(Q_OS_QNX) @@ -839,7 +839,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) #endif } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index 83bcb7d751..57ae671897 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) #ifdef Q_OS_WINRT inline DWORD qWinRTTlsAlloc() { @@ -330,7 +330,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName) ** QThreadPrivate *************************************************************************/ -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *data) { @@ -342,7 +342,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat #endif } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(void *arg) Q_DECL_NOEXCEPT { @@ -444,7 +444,7 @@ void QThread::yieldCurrentThread() #endif } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) void QThread::sleep(unsigned long secs) { @@ -461,7 +461,7 @@ void QThread::usleep(unsigned long usecs) ::Sleep((usecs / 1000) + 1); } -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) void QThread::start(Priority priority) { @@ -699,6 +699,6 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority) } } -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index 157cbeaf4d..ea2c611082 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -43,8 +43,6 @@ #include <algorithm> -#ifndef QT_NO_THREAD - QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QThreadPool, theInstance) @@ -730,5 +728,3 @@ void QThreadPool::cancel(QRunnable *runnable) QT_END_NAMESPACE #include "moc_qthreadpool.cpp" - -#endif diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h index 606e192768..cd27b7c08a 100644 --- a/src/corelib/thread/qthreadpool.h +++ b/src/corelib/thread/qthreadpool.h @@ -45,7 +45,7 @@ #include <QtCore/qthread.h> #include <QtCore/qrunnable.h> -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -97,6 +97,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_THREAD - #endif diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h index d03ba9d77f..0e6a00d243 100644 --- a/src/corelib/thread/qthreadpool_p.h +++ b/src/corelib/thread/qthreadpool_p.h @@ -59,7 +59,7 @@ #include "QtCore/qqueue.h" #include "private/qobject_p.h" -#ifndef QT_NO_THREAD +QT_REQUIRE_CONFIG(thread); QT_BEGIN_NAMESPACE @@ -184,5 +184,4 @@ public: QT_END_NAMESPACE -#endif // QT_NO_THREAD #endif diff --git a/src/corelib/thread/qthreadstorage.cpp b/src/corelib/thread/qthreadstorage.cpp index c0b523a431..8b82118a5c 100644 --- a/src/corelib/thread/qthreadstorage.cpp +++ b/src/corelib/thread/qthreadstorage.cpp @@ -39,7 +39,6 @@ #include "qthreadstorage.h" -#ifndef QT_NO_THREAD #include "qthread.h" #include "qthread_p.h" #include "qmutex.h" @@ -323,6 +322,4 @@ void QThreadStorageData::finish(void **p) \sa localData(), hasLocalData() */ -#endif // QT_NO_THREAD - QT_END_NAMESPACE diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h index 9a91883de8..d556e33c57 100644 --- a/src/corelib/thread/qthreadstorage.h +++ b/src/corelib/thread/qthreadstorage.h @@ -42,7 +42,7 @@ #include <QtCore/qglobal.h> -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) QT_BEGIN_NAMESPACE @@ -152,7 +152,7 @@ public: QT_END_NAMESPACE -#else // !QT_NO_THREAD +#else // !QT_CONFIG(thread) #include <qscopedpointer.h> @@ -227,6 +227,6 @@ public: } }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) #endif // QTHREADSTORAGE_H diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h index e42efbdfca..11520e4cfe 100644 --- a/src/corelib/thread/qwaitcondition.h +++ b/src/corelib/thread/qwaitcondition.h @@ -46,8 +46,7 @@ QT_BEGIN_NAMESPACE - -#ifndef QT_NO_THREAD +#if QT_CONFIG(thread) class QDeadlineTimer; class QWaitConditionPrivate; @@ -98,7 +97,7 @@ public: void wakeAll() {} }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) QT_END_NAMESPACE diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index 9706be1504..c93328b4bc 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -56,8 +56,6 @@ #include <sys/time.h> #include <time.h> -#ifndef QT_NO_THREAD - QT_BEGIN_NAMESPACE #ifdef Q_OS_ANDROID @@ -264,5 +262,3 @@ bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline } QT_END_NAMESPACE - -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index 61e4c2bcb1..534456a935 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -45,8 +45,6 @@ #include "qlist.h" #include "qalgorithms.h" -#ifndef QT_NO_THREAD - #define Q_MUTEX_T void* #include <private/qmutex_p.h> #include <private/qreadwritelock_p.h> @@ -247,4 +245,3 @@ void QWaitCondition::wakeAll() } QT_END_NAMESPACE -#endif // QT_NO_THREAD diff --git a/src/corelib/thread/thread.pri b/src/corelib/thread/thread.pri index dae72564b4..22f0de0523 100644 --- a/src/corelib/thread/thread.pri +++ b/src/corelib/thread/thread.pri @@ -1,38 +1,66 @@ # Qt core thread module -# public headers -HEADERS += thread/qmutex.h \ - thread/qrunnable.h \ - thread/qreadwritelock.h \ - thread/qsemaphore.h \ - thread/qthread.h \ - thread/qthreadpool.h \ - thread/qthreadstorage.h \ - thread/qwaitcondition.h \ - thread/qatomic.h \ - thread/qatomic_bootstrap.h \ - thread/qatomic_cxx11.h \ - thread/qbasicatomic.h \ - thread/qgenericatomic.h +HEADERS += \ + thread/qmutex.h \ + thread/qreadwritelock.h \ + thread/qrunnable.h \ + thread/qthread.h \ + thread/qthreadstorage.h \ + thread/qwaitcondition.h -# private headers -HEADERS += thread/qmutex_p.h \ - thread/qmutexpool_p.h \ - thread/qfutex_p.h \ - thread/qorderedmutexlocker_p.h \ - thread/qreadwritelock_p.h \ - thread/qthread_p.h \ - thread/qthreadpool_p.h +SOURCES += \ + thread/qrunnable.cpp \ + thread/qthread.cpp -SOURCES += thread/qatomic.cpp \ - thread/qmutex.cpp \ - thread/qreadwritelock.cpp \ - thread/qrunnable.cpp \ - thread/qmutexpool.cpp \ - thread/qsemaphore.cpp \ - thread/qthread.cpp \ - thread/qthreadpool.cpp \ - thread/qthreadstorage.cpp +win32 { + HEADERS += thread/qatomic_msvc.h + + SOURCES += thread/qthread_win.cpp +} else { + SOURCES += thread/qthread_unix.cpp +} + +qtConfig(thread) { + HEADERS += \ + thread/qatomic.h \ + thread/qatomic_bootstrap.h \ + thread/qatomic_cxx11.h \ + thread/qbasicatomic.h \ + thread/qfutex_p.h \ + thread/qgenericatomic.h \ + thread/qmutexpool_p.h \ + thread/qmutex_p.h \ + thread/qorderedmutexlocker_p.h \ + thread/qreadwritelock_p.h \ + thread/qsemaphore.h \ + thread/qthreadpool.h \ + thread/qthreadpool_p.h \ + thread/qthread_p.h + + SOURCES += \ + thread/qatomic.cpp \ + thread/qmutex.cpp \ + thread/qmutexpool.cpp \ + thread/qreadwritelock.cpp \ + thread/qsemaphore.cpp \ + thread/qthreadpool.cpp \ + thread/qthreadstorage.cpp + + win32 { + SOURCES += \ + thread/qmutex_win.cpp \ + thread/qwaitcondition_win.cpp + } else { + darwin { + SOURCES += thread/qmutex_mac.cpp + } else: linux { + SOURCES += thread/qmutex_linux.cpp + } else { + SOURCES += thread/qmutex_unix.cpp + } + SOURCES += thread/qwaitcondition_unix.cpp + } +} qtConfig(future) { HEADERS += \ @@ -52,24 +80,4 @@ qtConfig(future) { thread/qresultstore.cpp } -win32 { - HEADERS += thread/qatomic_msvc.h - - SOURCES += \ - thread/qmutex_win.cpp \ - thread/qthread_win.cpp \ - thread/qwaitcondition_win.cpp -} else { - darwin { - SOURCES += thread/qmutex_mac.cpp - } else: linux { - SOURCES += thread/qmutex_linux.cpp - } else { - SOURCES += thread/qmutex_unix.cpp - } - SOURCES += \ - thread/qthread_unix.cpp \ - thread/qwaitcondition_unix.cpp -} - qtConfig(std-atomic64): QMAKE_USE += libatomic diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 288c7963d9..58755c94bb 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2339,7 +2339,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT // localtime_r() does not have this requirement, so make an explicit call. // The explicit call should also request the timezone info be re-parsed. qt_tzset(); -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) +#if QT_CONFIG(thread) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) // Use the reentrant version of localtime() where available // as is thread-safe and doesn't use a shared static data area tm *res = 0; |