diff options
Diffstat (limited to 'src/corelib/thread/qthread_p.h')
-rw-r--r-- | src/corelib/thread/qthread_p.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 46294a5fc8..64e3f33191 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,15 +212,17 @@ public: } }; -#else // QT_NO_THREAD +#else // QT_CONFIG(thread) class QThreadPrivate : public QObjectPrivate { public: - QThreadPrivate(QThreadData *d = 0) : data(d ? d : new QThreadData) {} - ~QThreadPrivate() { delete data; } + QThreadPrivate(QThreadData *d = 0); + ~QThreadPrivate(); + mutable QMutex mutex; QThreadData *data; + bool running = false; static void setCurrentThread(QThread*) {} static QThread *threadForId(int) { return QThread::currentThread(); } @@ -230,7 +234,7 @@ public: Q_DECLARE_PUBLIC(QThread) }; -#endif // QT_NO_THREAD +#endif // QT_CONFIG(thread) class QThreadData { @@ -247,7 +251,15 @@ public: void ref(); void deref(); inline bool hasEventDispatcher() const - { return eventDispatcher.load() != 0; } + { return eventDispatcher.load() != nullptr; } + QAbstractEventDispatcher *createEventDispatcher(); + QAbstractEventDispatcher *ensureEventDispatcher() + { + QAbstractEventDispatcher *ed = eventDispatcher.load(); + if (Q_LIKELY(ed)) + return ed; + return createEventDispatcher(); + } bool canWaitLocked() { @@ -318,7 +330,9 @@ public: void init(); private: +#if QT_CONFIG(thread) void run() override; +#endif }; QT_END_NAMESPACE |