mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-22 12:33:29 +00:00
32 lines
591 B
C++
32 lines
591 B
C++
#pragma once
|
|
|
|
#include <atomic>
|
|
|
|
#include <QObject>
|
|
#include <QThread>
|
|
#include <QTimer>
|
|
|
|
#include "../../Machines/Utility/MachineForTarget.hpp"
|
|
#include "functionthread.h"
|
|
|
|
class Timer : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit Timer(QObject *parent = nullptr);
|
|
~Timer();
|
|
|
|
void startWithMachine(MachineTypes::TimedMachine *machine, std::mutex *machineMutex);
|
|
|
|
public slots:
|
|
void tick();
|
|
|
|
private:
|
|
MachineTypes::TimedMachine *machine = nullptr;
|
|
std::mutex *machineMutex = nullptr;
|
|
int64_t lastTickNanos = 0;
|
|
FunctionThread thread;
|
|
std::unique_ptr<QTimer> timer;
|
|
};
|