summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qexception.cpp20
-rw-r--r--src/corelib/thread/qexception.h16
-rw-r--r--src/corelib/thread/qfuture.qdoc1
-rw-r--r--src/corelib/thread/qfutureinterface.h2
-rw-r--r--src/corelib/thread/qfuturewatcher.h4
-rw-r--r--src/corelib/thread/qgenericatomic.h81
-rw-r--r--src/corelib/thread/qmutex.h8
-rw-r--r--src/corelib/thread/qmutex_win.cpp6
-rw-r--r--src/corelib/thread/qresultstore.h4
-rw-r--r--src/corelib/thread/qrunnable.cpp11
-rw-r--r--src/corelib/thread/qrunnable.h9
-rw-r--r--src/corelib/thread/qthread.cpp28
-rw-r--r--src/corelib/thread/qthread.h4
-rw-r--r--src/corelib/thread/qthread_p.h10
-rw-r--r--src/corelib/thread/qthread_unix.cpp15
-rw-r--r--src/corelib/thread/qthread_win.cpp6
-rw-r--r--src/corelib/thread/qthreadpool.h2
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp2
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp6
19 files changed, 153 insertions, 82 deletions
diff --git a/src/corelib/thread/qexception.cpp b/src/corelib/thread/qexception.cpp
index acc3663936..04a03b8623 100644
--- a/src/corelib/thread/qexception.cpp
+++ b/src/corelib/thread/qexception.cpp
@@ -107,6 +107,16 @@ QT_BEGIN_NAMESPACE
\internal
*/
+QException::~QException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+{
+ // must stay empty until ### Qt 6
+}
+
void QException::raise() const
{
QException e = *this;
@@ -118,6 +128,16 @@ QException *QException::clone() const
return new QException(*this);
}
+QUnhandledException::~QUnhandledException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+{
+ // must stay empty until ### Qt 6
+}
+
void QUnhandledException::raise() const
{
QUnhandledException e = *this;
diff --git a/src/corelib/thread/qexception.h b/src/corelib/thread/qexception.h
index 55fc441020..b15ae5095a 100644
--- a/src/corelib/thread/qexception.h
+++ b/src/corelib/thread/qexception.h
@@ -53,6 +53,13 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QException : public std::exception
{
public:
+ ~QException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+ ;
virtual void raise() const;
virtual QException *clone() const;
};
@@ -60,6 +67,13 @@ public:
class Q_CORE_EXPORT QUnhandledException : public QException
{
public:
+ ~QUnhandledException()
+#ifdef Q_COMPILER_NOEXCEPT
+ noexcept
+#else
+ throw()
+#endif
+ ;
void raise() const Q_DECL_OVERRIDE;
QUnhandledException *clone() const Q_DECL_OVERRIDE;
};
@@ -70,7 +84,7 @@ class Base;
class Q_CORE_EXPORT ExceptionHolder
{
public:
- ExceptionHolder(QException *exception = 0);
+ ExceptionHolder(QException *exception = Q_NULLPTR);
ExceptionHolder(const ExceptionHolder &other);
void operator=(const ExceptionHolder &other);
~ExceptionHolder();
diff --git a/src/corelib/thread/qfuture.qdoc b/src/corelib/thread/qfuture.qdoc
index be4cee2bd6..ed0b26e121 100644
--- a/src/corelib/thread/qfuture.qdoc
+++ b/src/corelib/thread/qfuture.qdoc
@@ -352,6 +352,7 @@
/*! \class QFuture::const_iterator
\reentrant
\since 4.4
+ \inmodule QtCore
\brief The QFuture::const_iterator class provides an STL-style const
iterator for QFuture.
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index 01eb043a5e..8c1f7e7d82 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -299,7 +299,7 @@ public:
void reportResult(const void *, int) { }
void reportResults(const QVector<void> &, int) { }
- void reportFinished(const void * = 0) { QFutureInterfaceBase::reportFinished(); }
+ void reportFinished(const void * = Q_NULLPTR) { QFutureInterfaceBase::reportFinished(); }
};
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qfuturewatcher.h b/src/corelib/thread/qfuturewatcher.h
index 63558d4a0f..42a22d9063 100644
--- a/src/corelib/thread/qfuturewatcher.h
+++ b/src/corelib/thread/qfuturewatcher.h
@@ -52,7 +52,7 @@ class Q_CORE_EXPORT QFutureWatcherBase : public QObject
Q_DECLARE_PRIVATE(QFutureWatcherBase)
public:
- explicit QFutureWatcherBase(QObject *parent = 0);
+ explicit QFutureWatcherBase(QObject *parent = Q_NULLPTR);
// de-inline dtor
int progressValue() const;
@@ -179,7 +179,7 @@ template <>
class QFutureWatcher<void> : public QFutureWatcherBase
{
public:
- explicit QFutureWatcher(QObject *_parent = 0)
+ explicit QFutureWatcher(QObject *_parent = Q_NULLPTR)
: QFutureWatcherBase(_parent)
{ }
~QFutureWatcher()
diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h
index a9a790c14c..d3e7d51efd 100644
--- a/src/corelib/thread/qgenericatomic.h
+++ b/src/corelib/thread/qgenericatomic.h
@@ -46,13 +46,6 @@ QT_END_NAMESPACE
#pragma qt_sync_stop_processing
#endif
-#ifdef Q_CC_GNU
-// lowercase is fine, we'll undef it below
-#define always_inline __attribute__((always_inline, gnu_inline))
-#else
-#define always_inline
-#endif
-
template<int> struct QAtomicOpsSupport { enum { IsSupported = 0 }; };
template<> struct QAtomicOpsSupport<4> { enum { IsSupported = 1 }; };
@@ -84,19 +77,19 @@ template <typename BaseClass> struct QGenericAtomicOps
{
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T load(const T &_q_value) Q_DECL_NOTHROW
{
return _q_value;
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
void store(T &_q_value, X newValue) Q_DECL_NOTHROW
{
_q_value = newValue;
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T loadAcquire(const T &_q_value) Q_DECL_NOTHROW
{
T tmp = *static_cast<const volatile T *>(&_q_value);
@@ -104,7 +97,7 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
void storeRelease(T &_q_value, X newValue) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
@@ -115,13 +108,13 @@ template <typename BaseClass> struct QGenericAtomicOps
{ return BaseClass::isFetchAndAddNative(); }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW
{ return BaseClass::isFetchAndAddWaitFree(); }
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
bool ref(T &_q_value) Q_DECL_NOTHROW
{
return BaseClass::fetchAndAddRelaxed(_q_value, 1) != T(-1);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
bool deref(T &_q_value) Q_DECL_NOTHROW
{
return BaseClass::fetchAndAddRelaxed(_q_value, -1) != 1;
@@ -138,7 +131,7 @@ template <typename BaseClass> struct QGenericAtomicOps
bool testAndSetRelaxed(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW;
#endif
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW
{
bool tmp = BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue);
@@ -146,21 +139,21 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
bool testAndSetRelease(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue);
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue);
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
bool testAndSetAcquire(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW
{
bool tmp = BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue);
@@ -168,14 +161,14 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
bool testAndSetRelease(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::testAndSetRelaxed(_q_value, expectedValue, newValue, currentValue);
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
bool testAndSetOrdered(T &_q_value, X expectedValue, X newValue, X *currentValue) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
@@ -185,7 +178,7 @@ template <typename BaseClass> struct QGenericAtomicOps
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
T fetchAndStoreRelaxed(T &_q_value, X newValue) Q_DECL_NOTHROW
{
// implement fetchAndStore on top of testAndSet
@@ -196,7 +189,7 @@ template <typename BaseClass> struct QGenericAtomicOps
}
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
T fetchAndStoreAcquire(T &_q_value, X newValue) Q_DECL_NOTHROW
{
T tmp = BaseClass::fetchAndStoreRelaxed(_q_value, newValue);
@@ -204,14 +197,14 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
T fetchAndStoreRelease(T &_q_value, X newValue) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndStoreRelaxed(_q_value, newValue);
}
- template <typename T, typename X> static inline always_inline
+ template <typename T, typename X> static Q_ALWAYS_INLINE
T fetchAndStoreOrdered(T &_q_value, X newValue) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
@@ -220,7 +213,7 @@ template <typename BaseClass> struct QGenericAtomicOps
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
// implement fetchAndAdd on top of testAndSet
@@ -231,7 +224,7 @@ template <typename BaseClass> struct QGenericAtomicOps
}
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
T tmp = BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd);
@@ -239,28 +232,28 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAddRelease(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAddOrdered(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndAddRelaxed(_q_value, valueToAdd);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndSubRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT operand) Q_DECL_NOTHROW
{
// implement fetchAndSub on top of fetchAndAdd
return fetchAndAddRelaxed(_q_value, -operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndSubAcquire(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT operand) Q_DECL_NOTHROW
{
T tmp = BaseClass::fetchAndSubRelaxed(_q_value, operand);
@@ -268,21 +261,21 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndSubRelease(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT operand) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndSubRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndSubOrdered(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT operand) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndSubRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndRelaxed(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
// implement fetchAndAnd on top of testAndSet
@@ -293,7 +286,7 @@ template <typename BaseClass> struct QGenericAtomicOps
}
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndAcquire(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
T tmp = BaseClass::fetchAndAndRelaxed(_q_value, operand);
@@ -301,21 +294,21 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndRelease(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndAndRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndAndOrdered(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndAndRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrRelaxed(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
// implement fetchAndOr on top of testAndSet
@@ -326,7 +319,7 @@ template <typename BaseClass> struct QGenericAtomicOps
}
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrAcquire(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
T tmp = BaseClass::fetchAndOrRelaxed(_q_value, operand);
@@ -334,21 +327,21 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrRelease(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndOrRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndOrOrdered(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
return BaseClass::fetchAndOrRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorRelaxed(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
// implement fetchAndXor on top of testAndSet
@@ -359,7 +352,7 @@ template <typename BaseClass> struct QGenericAtomicOps
}
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorAcquire(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
T tmp = BaseClass::fetchAndXorRelaxed(_q_value, operand);
@@ -367,14 +360,14 @@ template <typename BaseClass> struct QGenericAtomicOps
return tmp;
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorRelease(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
BaseClass::releaseMemoryFence(_q_value);
return BaseClass::fetchAndXorRelaxed(_q_value, operand);
}
- template <typename T> static inline always_inline
+ template <typename T> static Q_ALWAYS_INLINE
T fetchAndXorOrdered(T &_q_value, typename QtPrivate::QEnableIf<QTypeInfo<T>::isIntegral, T>::Type operand) Q_DECL_NOTHROW
{
BaseClass::orderedMemoryFence(_q_value);
@@ -382,7 +375,5 @@ template <typename BaseClass> struct QGenericAtomicOps
}
};
-#undef always_inline
-
QT_END_NAMESPACE
#endif // QGENERICATOMIC_H
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 63c488747f..0c5a73b4df 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -73,16 +73,16 @@ public:
private:
inline bool fastTryLock() Q_DECL_NOTHROW {
- return d_ptr.testAndSetAcquire(0, dummyLocked());
+ return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked());
}
inline bool fastTryUnlock() Q_DECL_NOTHROW {
- return d_ptr.testAndSetRelease(dummyLocked(), 0);
+ return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR);
}
inline bool fastTryLock(QMutexData *&current) Q_DECL_NOTHROW {
- return d_ptr.testAndSetAcquire(0, dummyLocked(), current);
+ return d_ptr.testAndSetAcquire(Q_NULLPTR, dummyLocked(), current);
}
inline bool fastTryUnlock(QMutexData *&current) Q_DECL_NOTHROW {
- return d_ptr.testAndSetRelease(dummyLocked(), 0, current);
+ return d_ptr.testAndSetRelease(dummyLocked(), Q_NULLPTR, current);
}
void lockInternal() QT_MUTEX_LOCK_NOEXCEPT;
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index c4130fdba5..c24ea58868 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -55,10 +55,10 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout)
{
-#ifndef Q_OS_WINRT
- return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
-#else
+#ifndef Q_OS_WINCE
return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0);
+#else
+ return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
#endif
}
diff --git a/src/corelib/thread/qresultstore.h b/src/corelib/thread/qresultstore.h
index fbcb8ad3cd..7ecaa231b2 100644
--- a/src/corelib/thread/qresultstore.h
+++ b/src/corelib/thread/qresultstore.h
@@ -61,8 +61,8 @@ class ResultItem
public:
ResultItem(const void *_result, int _count) : m_count(_count), result(_result) { } // contruct with vector of results
ResultItem(const void *_result) : m_count(0), result(_result) { } // construct with result
- ResultItem() : m_count(0), result(0) { }
- bool isValid() const { return result != 0; }
+ ResultItem() : m_count(0), result(Q_NULLPTR) { }
+ bool isValid() const { return result != Q_NULLPTR; }
bool isVector() const { return m_count != 0; }
int count() const { return (m_count == 0) ? 1 : m_count; }
int m_count; // result is either a pointer to a result or to a vector of results,
diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp
index 64a2613d27..04aa39a81e 100644
--- a/src/corelib/thread/qrunnable.cpp
+++ b/src/corelib/thread/qrunnable.cpp
@@ -31,6 +31,15 @@
**
****************************************************************************/
+#include "qrunnable.h"
+
+QT_BEGIN_NAMESPACE
+
+QRunnable::~QRunnable()
+{
+ // Must be empty until ### Qt 6
+}
+
/*!
\class QRunnable
\inmodule QtCore
@@ -98,3 +107,5 @@
\sa autoDelete(), QThreadPool
*/
+
+QT_END_NAMESPACE
diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h
index f00c58d51d..28d14a46c0 100644
--- a/src/corelib/thread/qrunnable.h
+++ b/src/corelib/thread/qrunnable.h
@@ -38,20 +38,21 @@
QT_BEGIN_NAMESPACE
-
-class QRunnable
+class Q_CORE_EXPORT QRunnable
{
int ref;
friend class QThreadPool;
friend class QThreadPoolPrivate;
friend class QThreadPoolThread;
-
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ Q_DISABLE_COPY(QRunnable)
+#endif
public:
virtual void run() = 0;
QRunnable() : ref(0) { }
- virtual ~QRunnable() { }
+ virtual ~QRunnable();
bool autoDelete() const { return ref != -1; }
void setAutoDelete(bool _autoDelete) { ref = _autoDelete ? 0 : -1; }
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index dc231a00f8..590479d68c 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -38,7 +38,6 @@
#include "qabstracteventdispatcher.h"
#include <qeventloop.h>
-#include <qhash.h>
#include "qthread_p.h"
#include "private/qcoreapplication_p.h"
@@ -51,7 +50,8 @@ QT_BEGIN_NAMESPACE
QThreadData::QThreadData(int initialRefCount)
: _ref(initialRefCount), loopLevel(0), thread(0), threadId(0),
- eventDispatcher(0), quitNow(false), canWait(true), isAdopted(false)
+ eventDispatcher(0),
+ quitNow(false), canWait(true), isAdopted(false), requiresCoreApplication(true)
{
// fprintf(stderr, "QThreadData %p created\n", this);
}
@@ -868,4 +868,28 @@ bool QThread::isInterruptionRequested() const
return d->interruptionRequested;
}
+/*!
+ \class QDaemonThread
+ \since 5.5
+ \brief The QDaemonThread provides a class to manage threads that outlive QCoreApplication
+ \internal
+
+ Note: don't try to deliver events from the started() signal.
+*/
+static void setThreadDoesNotRequireCoreApplication()
+{
+ QThreadData::current()->requiresCoreApplication = false;
+}
+
+QDaemonThread::QDaemonThread(QObject *parent)
+ : QThread(parent)
+{
+ // QThread::started() is emitted from the thread we start
+ connect(this, &QThread::started, setThreadDoesNotRequireCoreApplication);
+}
+
+QDaemonThread::~QDaemonThread()
+{
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index bfc469583d..d333980bf4 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -55,7 +55,7 @@ public:
static int idealThreadCount() Q_DECL_NOTHROW;
static void yieldCurrentThread();
- explicit QThread(QObject *parent = 0);
+ explicit QThread(QObject *parent = Q_NULLPTR);
~QThread();
enum Priority {
@@ -116,7 +116,7 @@ protected:
static void setTerminationEnabled(bool enabled = true);
protected:
- QThread(QThreadPrivate &dd, QObject *parent = 0);
+ QThread(QThreadPrivate &dd, QObject *parent = Q_NULLPTR);
private:
Q_DECLARE_PRIVATE(QThread)
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 1ecd682ad1..ffefe0b1d1 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -135,6 +135,13 @@ private:
#ifndef QT_NO_THREAD
+class Q_CORE_EXPORT QDaemonThread : public QThread
+{
+public:
+ QDaemonThread(QObject *parent = 0);
+ ~QDaemonThread();
+};
+
class QThreadPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QThread)
@@ -224,7 +231,7 @@ public:
QThreadData(int initialRefCount = 1);
~QThreadData();
- static QThreadData *current(bool createIfNecessary = true);
+ static Q_AUTOTEST_EXPORT QThreadData *current(bool createIfNecessary = true);
static void clearCurrentThreadData();
static QThreadData *get2(QThread *thread)
{ Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; }
@@ -278,6 +285,7 @@ public:
bool quitNow;
bool canWait;
bool isAdopted;
+ bool requiresCoreApplication;
};
class QScopedLoopLevelCounter
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 77093c9cf1..f054a727cf 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -313,14 +313,15 @@ void *QThreadPrivate::start(void *arg)
createEventDispatcher(data);
#if (defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_QNX))
- // sets the name of the current thread.
- QString objectName = thr->objectName();
-
- if (Q_LIKELY(objectName.isEmpty()))
- setCurrentThreadName(thr->d_func()->thread_id, thr->metaObject()->className());
- else
- setCurrentThreadName(thr->d_func()->thread_id, objectName.toLocal8Bit());
+ {
+ // sets the name of the current thread.
+ QString objectName = thr->objectName();
+ if (Q_LIKELY(objectName.isEmpty()))
+ setCurrentThreadName(thr->d_func()->thread_id, thr->metaObject()->className());
+ else
+ setCurrentThreadName(thr->d_func()->thread_id, objectName.toLocal8Bit());
+ }
#endif
emit thr->started(QThread::QPrivateSignal());
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index c16a2e958c..57eeb10b7d 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -118,7 +118,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
}
threadData->deref();
threadData->isAdopted = true;
- threadData->threadId = reinterpret_cast<Qt::HANDLE>(GetCurrentThreadId());
+ threadData->threadId = reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()));
if (!QCoreApplicationPrivate::theMainThread) {
QCoreApplicationPrivate::theMainThread = threadData->thread;
@@ -340,7 +340,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
qt_create_tls();
TlsSetValue(qt_current_thread_data_tls_index, data);
- data->threadId = reinterpret_cast<Qt::HANDLE>(GetCurrentThreadId());
+ data->threadId = reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()));
QThread::setTerminationEnabled(false);
@@ -413,7 +413,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway)
Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
{
- return reinterpret_cast<Qt::HANDLE>(GetCurrentThreadId());
+ return reinterpret_cast<Qt::HANDLE>(quintptr(GetCurrentThreadId()));
}
int QThread::idealThreadCount() Q_DECL_NOTHROW
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index b1ca808a99..95b41a0417 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -55,7 +55,7 @@ class Q_CORE_EXPORT QThreadPool : public QObject
friend class QFutureInterfaceBase;
public:
- QThreadPool(QObject *parent = 0);
+ QThreadPool(QObject *parent = Q_NULLPTR);
~QThreadPool();
static QThreadPool *globalInstance();
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index fd6af7db39..89bf523263 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -77,7 +77,7 @@ void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
#if defined(Q_OS_ANDROID)
if (local_condattr_setclock && QElapsedTimer::clockType() == QElapsedTimer::MonotonicClock)
local_condattr_setclock(&condattr, CLOCK_MONOTONIC);
-#elif !defined(Q_OS_MAC) && !defined(Q_OS_HAIKU)
+#elif !defined(Q_OS_MAC)
if (QElapsedTimer::clockType() == QElapsedTimer::MonotonicClock)
pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
#endif
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp
index ef8330570e..3ea34461d3 100644
--- a/src/corelib/thread/qwaitcondition_win.cpp
+++ b/src/corelib/thread/qwaitcondition_win.cpp
@@ -109,10 +109,10 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
{
// wait for the event
bool ret = false;
-#ifndef Q_OS_WINRT
- switch (WaitForSingleObject(wce->event, time)) {
-#else
+#ifndef Q_OS_WINCE
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
+#else
+ switch (WaitForSingleObject(wce->event, time)) {
#endif
default: break;