Files
pilotclient/src/misc/threadedtimer.h
Lars Toenning 5004db1885 refactor: Use composition for update time
The timer is not required by all classes and the deep inheritance makes
it hard to see where it is actually used. Use composition instead.
2025-06-10 21:39:52 +02:00

43 lines
1.0 KiB
C++

// SPDX-FileCopyrightText: Copyright (C) 2025 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \file
#ifndef SWIFT_MISC_THREADED_TIMER_H
#define SWIFT_MISC_THREADED_TIMER_H
#include <QObject>
#include <QTimer>
#include "misc/swiftmiscexport.h"
namespace swift::misc
{
//! Thread-safe timer class
class SWIFT_MISC_EXPORT CThreadedTimer : public QObject
{
Q_OBJECT
public:
CThreadedTimer(QObject *owner, const QString &name, bool singleShot = false);
//! Destructor
~CThreadedTimer() override = default;
//! Start updating (start timer)
//! \threadsafe
void startTimer(std::chrono::milliseconds ms);
//! Safely stop update time
//! \threadsafe
void stopTimer();
signals:
void timeout();
private:
QTimer m_updateTimer { this }; //!< timer which can be used by implementing classes
};
} // namespace swift::misc
#endif // SWIFT_MISC_THREADED_TIMER_H