12 CThreadedTimer::CThreadedTimer(QObject *owner,
const QString &name,
bool singleShot) : QObject(owner)
14 m_updateTimer.setObjectName(name +
":timer");
16 connect(&m_updateTimer, &QTimer::timeout,
this, &CThreadedTimer::timeout);
19 void CThreadedTimer::startTimer(std::chrono::milliseconds ms)
21 if (!CThreadUtils::isInThisThread(
this))
24 QPointer<CThreadedTimer> myself(
this);
26 if (!myself) {
return; }
32 connect(thread(), &QThread::finished, &m_updateTimer, &QTimer::stop, Qt::UniqueConnection);
33 m_updateTimer.start(ms);
36 void CThreadedTimer::stopTimer()
38 if (!CThreadUtils::isInThisThread(
this))
41 QPointer<CThreadedTimer> myself(
this);
43 if (!myself) {
return; }
49 if (!m_updateTimer.isActive()) {
return; }
Free functions in swift::misc.
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...