6 #ifndef SWIFT_MISC_THREADUTILS_H
7 #define SWIFT_MISC_THREADUTILS_H
11 #include <QMetaObject>
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);
59 static bool isInThisThread(
const QObject *toBeTested);
64 static bool thisIsMainThread();
67 static QString currentThreadInfo();
A promise-based interface to QFuture, similar to std::promise for std::future.
QFuture< T > future()
Return a future that can be used to access the result.
void setResultFrom(F &&func)
Invoke a functor and use its return value to set the result.
Utility class for threaded operations.
CThreadUtils()=delete
No constructor.
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.