44 #include <QtCore/qobject.h>
45 #include <QtCore/qdeadlinetimer.h>
48 #if QT_CONFIG(cxx11_future)
50 # include <functional>
53 #if defined(Q_CC_MSVC) && defined(Q_PROCESSOR_X86)
69 static QThread *currentThread();
70 static int idealThreadCount() noexcept;
71 static void yieldCurrentThread();
93 bool isFinished()
const;
94 bool isRunning()
const;
99 void setStackSize(
uint stackSize);
100 uint stackSize()
const;
108 #if QT_CONFIG(cxx11_future) || defined(Q_CLANG_QDOC)
116 void exit(
int retcode = 0);
123 if (
time == (std::numeric_limits<unsigned long>::max)())
128 static void sleep(
unsigned long);
129 static void msleep(
unsigned long);
130 static void usleep(
unsigned long);
148 #if QT_CONFIG(cxx11_future)
149 [[nodiscard]]
static QThread *createThreadImpl(std::future<void> &&
future);
157 #if QT_CONFIG(cxx11_future)
162 auto threadFunction =
163 [
f =
static_cast<DecayedFunction
>(std::forward<Function>(
f))](
auto &&... largs)
mutable ->
void
165 (
void)std::invoke(std::move(
f), std::forward<decltype(largs)>(largs)...);
168 return createThreadImpl(std::async(std::launch::deferred,
169 std::move(threadFunction),
170 std::forward<Args>(
args)...));
190 #define QT_HAS_FAST_CURRENT_THREAD_ID
192 static_assert(
sizeof(tid) ==
sizeof(
void*));
194 #if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) && defined(__GLIBC__)
195 __asm__(
"movl %%gs:%c1, %0" :
"=r" (tid) :
"i" (2 *
sizeof(
void*)) : );
196 #elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_DARWIN64)
198 __asm__(
"movq %%gs:0, %0" :
"=r" (tid) : : );
199 #elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_LINUX) && defined(__GLIBC__)) || defined(Q_OS_FREEBSD)
201 __asm__(
"movq %%fs:%c1, %0" :
"=r" (tid) :
"i" (2 *
sizeof(
void*)) : );
202 #elif defined(Q_PROCESSOR_X86_64) && defined(Q_OS_WIN)
206 # if defined(Q_CC_MINGW)
207 __asm__(
"movq %%gs:0x30, %0" :
"=r" (tib) : :);
209 tib =
reinterpret_cast<quint8 *
>(__readgsqword(0x30));
212 tid = *
reinterpret_cast<Qt::HANDLE *
>(tib + 0x48);
213 #elif defined(Q_PROCESSOR_X86_32) && defined(Q_OS_WIN)
216 # if defined(Q_CC_MINGW)
217 __asm__(
"movl %%fs:0x18, %0" :
"=r" (tib) : :);
219 tib =
reinterpret_cast<quint8 *
>(__readfsdword(0x18));
222 tid = *
reinterpret_cast<Qt::HANDLE *
>(tib + 0x24);
224 #undef QT_HAS_FAST_CURRENT_THREAD_ID
225 tid = currentThreadIdImpl();
The QAbstractEventDispatcher class provides an interface to manage Qt's event queue.
The QCoreApplication class provides an event loop for Qt applications without UI.
The QDeadlineTimer class marks a deadline in the future.
The QEvent class is the base class of all event classes. Event objects contain event parameters.
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *event)
bool isInterruptionRequested() const
static void setTerminationEnabled(bool enabled=true)
bool wait(unsigned long time)
static Qt::HANDLE currentThreadId() noexcept Q_DECL_PURE_FUNCTION
Priority priority() const
void finished(QPrivateSignal)
void setPriority(Priority priority)
void requestInterruption()
void started(QPrivateSignal)
#define Q_DECL_PURE_FUNCTION
GLenum GLenum GLsizei const GLuint GLboolean enabled
QFuture< void > future
[5]
QDeadlineTimer deadline(30s)
bool run(const QString &name, QString *errorMessage)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent