swift
threadedtimer.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2025 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_THREADED_TIMER_H
7 #define SWIFT_MISC_THREADED_TIMER_H
8 
9 #include <QObject>
10 #include <QTimer>
11 
12 #include "misc/swiftmiscexport.h"
13 
14 namespace swift::misc
15 {
17  class SWIFT_MISC_EXPORT CThreadedTimer : public QObject
18  {
19  Q_OBJECT
20  public:
21  CThreadedTimer(QObject *owner, const QString &name, bool singleShot = false);
22 
24  ~CThreadedTimer() override = default;
25 
28  void startTimer(std::chrono::milliseconds ms);
29 
32  void stopTimer();
33 
34  signals:
35  void timeout();
36 
37  private:
38  QTimer m_updateTimer { this };
39  };
40 } // namespace swift::misc
41 
42 #endif // SWIFT_MISC_THREADED_TIMER_H
Thread-safe timer class.
Definition: threadedtimer.h:18
~CThreadedTimer()=default
Destructor.
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...
Definition: threadutils.h:30
#define SWIFT_MISC_EXPORT
Export a class or function from the library.