6#ifndef SWIFT_MISC_THREADUTILS_H
7#define SWIFT_MISC_THREADUTILS_H
13#include <QSharedPointer>
35 timer->setSingleShot(
true);
36 timer->moveToThread(target->
thread());
38 [trace =
getStackTrace(), task = std::forward<F>(task), timer, promise]()
mutable {
39 static_cast<void>(trace);
41 promise.setResultFrom(task);
44 return promise.future();
A promise-based interface to QFuture, similar to std::promise for std::future.
static bool thisIsMainThread()
Is the current thread the application thread?
CThreadUtils()=delete
No constructor.
static QString currentThreadInfo()
Info about current thread, for debug messages.
static bool isInThisThread(const QObject *toBeTested)
Is the current thread the object's thread?
Free functions in swift::misc.
QStringList getStackTrace()
Returns a stack trace of the current thread of execution as a list of function names.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QThread * thread() const const
#define SWIFT_MISC_EXPORT
Export a class or function from the library.