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>
bb10
Morten Johan Sørvig 2018-07-02 22:24:35 +02:00 committed by Lorn Potter
parent 0a06e1baf9
commit 67352c9276
3 changed files with 70 additions and 31 deletions

View File

@ -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;

View File

@ -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

View File

@ -222,6 +222,7 @@ public:
mutable QMutex mutex;
QThreadData *data;
bool running = false;
static void setCurrentThread(QThread*) {}
static QThread *threadForId(int) { return QThread::currentThread(); }