swift
threadedreaderperiodic.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_CORE_THREADED_READER_PERIODIC_H
7 #define SWIFT_CORE_THREADED_READER_PERIODIC_H
8 
9 #include <QObject>
10 #include <QString>
11 
12 #include "core/swiftcoreexport.h"
13 #include "core/threadedreader.h"
14 #include "misc/threadedtimer.h"
15 
16 namespace swift::core
17 {
20  {
21  Q_OBJECT
22  public:
24  ~CThreadedReaderPeriodic() override = default;
25 
28  void startReader();
29 
30  protected:
32  CThreadedReaderPeriodic(QObject *owner, const QString &name);
33 
35  virtual void doWorkImpl() = 0;
36 
40  void setInitialAndPeriodicTime(std::chrono::milliseconds initialTime, std::chrono::milliseconds periodicTime);
41 
42  private:
44  void doWork();
45 
46  std::atomic<std::chrono::milliseconds> m_initialTime = std::chrono::milliseconds(0);
47  std::atomic<std::chrono::milliseconds> m_periodicTime =
48  std::chrono::milliseconds(0);
49 
50  misc::CThreadedTimer m_updateTimer;
51  };
52 } // namespace swift::core
53 
54 #endif // SWIFT_CORE_THREADED_READER_PERIODIC_H
Support for threaded based reading and parsing tasks such as data files via http, or file system and ...
Periodically executes doWorkImpl() in a separate thread.
virtual void doWorkImpl()=0
This method does the actual work in the derived class.
~CThreadedReaderPeriodic()=default
Destructor.
Thread-safe timer class.
Definition: threadedtimer.h:18
Backend services of the swift project, like dealing with the network or the simulators.
Definition: actionbind.cpp:7
#define SWIFT_CORE_EXPORT
Export a class or function from the library.