1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00
CLK/OSBindings/Qt/timer.h
Thomas Harte d08ffd6c8b Makes sure the timer really, really is on a different thread.
Thereby allows me substantially to reduce audio latency.
2020-06-14 23:22:00 -04:00

35 lines
629 B
C++

#ifndef TIMER_H
#define TIMER_H
#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;
};
#endif // TIMER_H