summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2018-07-02 22:24:35 +0200
committerLorn Potter <lorn.potter@gmail.com>2018-08-17 00:35:03 +0000
commit67352c92761fcb2e2c6a98b24e1bf5f33805cb3a (patch)
tree6d085f8ef3556469891bef40e23660d84cf767ec /src/corelib/thread
parent0a06e1baf9e6da5308582b9dc928f4d9fea508d0 (diff)
Merge QThread class definitions
We can reuse the main QThread definition for the no-thread configuration and avoid having to keep them in sync. Add stub definitions for member functions where needed. Change-Id: I128db11684a6040d09c4a4ce114f1399cba523f8 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.cpp69
-rw-r--r--src/corelib/thread/qthread.h31
-rw-r--r--src/corelib/thread/qthread_p.h1
3 files changed, 70 insertions, 31 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index a4101764bc..5df0508829 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -765,11 +765,80 @@ QThread::QThread(QObject *parent)
d->data->thread = this;
}
+QThread::~QThread()
+{
+
+}
+
+void QThread::run()
+{
+
+}
+
+int QThread::exec()
+{
+ return 0;
+}
+
+void QThread::start(Priority priority)
+{
+ Q_D(QThread);
+ Q_UNUSED(priority);
+ d->running = true;
+}
+
+void QThread::terminate()
+{
+
+}
+
+void QThread::quit()
+{
+
+}
+
+bool QThread::wait(unsigned long time)
+{
+ Q_UNUSED(time);
+ return false;
+}
+
+bool QThread::event(QEvent* event)
+{
+ return QObject::event(event);
+}
+
+Qt::HANDLE QThread::currentThreadId() Q_DECL_NOTHROW
+{
+ return Qt::HANDLE(currentThread());
+}
+
QThread *QThread::currentThread()
{
return QThreadData::current()->thread;
}
+int QThread::idealThreadCount() Q_DECL_NOTHROW
+{
+ return 1;
+}
+
+void QThread::yieldCurrentThread()
+{
+
+}
+
+bool QThread::isFinished() const
+{
+ return false;
+}
+
+bool QThread::isRunning() const
+{
+ Q_D(const QThread);
+ return d->running;
+}
+
// No threads: so we can just use static variables
static QThreadData *data = 0;
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index d0ffd9f909..b6c5bf47d0 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -66,7 +66,6 @@ class QThreadData;
class QThreadPrivate;
class QAbstractEventDispatcher;
-#if QT_CONFIG(thread)
class Q_CORE_EXPORT QThread : public QObject
{
Q_OBJECT
@@ -239,36 +238,6 @@ QThread *QThread::create(Function &&f)
#endif // QT_CONFIG(cxx11_future)
-#else // QT_CONFIG(thread)
-
-class Q_CORE_EXPORT QThread : public QObject
-{
-public:
- static Qt::HANDLE currentThreadId() { return Qt::HANDLE(currentThread()); }
- static QThread* currentThread();
-
- static void sleep(unsigned long);
- static void msleep(unsigned long);
- static void usleep(unsigned long);
-
- QAbstractEventDispatcher *eventDispatcher() const;
- void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
-
-protected:
- QThread(QThreadPrivate &dd, QObject *parent = nullptr);
-
-private:
- explicit QThread(QObject *parent = nullptr);
- static QThread *instance;
-
- friend class QCoreApplication;
- friend class QThreadData;
- friend class QAdoptedThread;
- Q_DECLARE_PRIVATE(QThread)
-};
-
-#endif // QT_CONFIG(thread)
-
QT_END_NAMESPACE
#endif // QTHREAD_H
diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h
index 22a0669032..64e3f33191 100644
--- a/src/corelib/thread/qthread_p.h
+++ b/src/corelib/thread/qthread_p.h
@@ -222,6 +222,7 @@ public:
mutable QMutex mutex;
QThreadData *data;
+ bool running = false;
static void setCurrentThread(QThread*) {}
static QThread *threadForId(int) { return QThread::currentThread(); }