summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2017-01-02 17:23:14 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-06-22 07:14:29 +0000
commit31023ef553f3b26081f92a5d95a886f4d7cffdd9 (patch)
treeb720c725dc99aca3bdec5393e616da94fd87570a /src/corelib/thread
parent47aebe3587c7be28ed4fde23b77848657482ed66 (diff)
Make the sleep methods available in QThread even if QT_NO_THREAD
sleep, msleep, and usleep are not actually related to threading and serve a purpose also in a single threaded application. Change-Id: Iba2e343d48a9c09e60125bc1b589047e0241608a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthread.h4
-rw-r--r--src/corelib/thread/qthread_unix.cpp4
-rw-r--r--src/corelib/thread/qthread_win.cpp10
3 files changed, 16 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 3df76077e1..19951e844a 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -247,6 +247,10 @@ 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);
+
protected:
QThread(QThreadPrivate &dd, QObject *parent = nullptr);
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index 9ad32b162d..c5de46d07d 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -519,6 +519,8 @@ void QThread::yieldCurrentThread()
sched_yield();
}
+#endif // QT_NO_THREAD
+
static timespec makeTimespec(time_t secs, long nsecs)
{
struct timespec ts;
@@ -542,6 +544,8 @@ void QThread::usleep(unsigned long usecs)
qt_nanosleep(makeTimespec(usecs / 1000 / 1000, usecs % (1000*1000) * 1000));
}
+#ifndef QT_NO_THREAD
+
#ifdef QT_HAS_THREAD_PRIORITY_SCHEDULING
#if defined(Q_OS_QNX)
static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority)
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 4459ae87af..6c9f939b7d 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -61,9 +61,10 @@
# include <process.h>
#endif // Q_OS_WINRT
-#ifndef QT_NO_THREAD
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_THREAD
+
#ifdef Q_OS_WINRT
inline DWORD qWinRTTlsAlloc() {
return FlsAlloc(0);
@@ -449,6 +450,8 @@ void QThread::yieldCurrentThread()
#endif
}
+#endif // QT_NO_THREAD
+
void QThread::sleep(unsigned long secs)
{
::Sleep(secs * 1000);
@@ -464,6 +467,8 @@ void QThread::usleep(unsigned long usecs)
::Sleep((usecs / 1000) + 1);
}
+#ifndef QT_NO_THREAD
+
void QThread::start(Priority priority)
{
Q_D(QThread);
@@ -700,5 +705,6 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
}
}
-QT_END_NAMESPACE
#endif // QT_NO_THREAD
+
+QT_END_NAMESPACE