6 #ifndef SWIFT_MISC_EVENTLOOP_H
7 #define SWIFT_MISC_EVENTLOOP_H
33 template <
typename T,
typename F>
40 template <
typename T,
typename F1,
typename F2>
41 void stopWhen(
const T *sender, F1 signal, F2 &&condition)
44 [
this, condition = std::forward<F2>(condition)](
auto &&...args) {
45 if (condition(std::forward<decltype(args)>(args)...)) { m_eventLoop.
exit(GotSignal); }
Utility class which blocks until a signal is emitted or timeout reached.
CEventLoop(QObject *guard)
Constructor. Guard object must exist, and will be checked again when the loop quits.
bool exec(int timeoutMs)
Begin processing events until the timeout or stop condition occurs.
bool isGuardAlive() const
True if the guard object still exists.
void stopWhen(const T *sender, F1 signal, F2 &&condition)
Event loop will stop if the given signal is received and condition returns true.
void stopWhen(const T *sender, F signal)
Event loop will stop if the given signal is received.
Free functions in swift::misc.
int exec(QEventLoop::ProcessEventsFlags flags)
void exit(int returnCode)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void destroyed(QObject *obj)