34 lines
556 B
C++
34 lines
556 B
C++
#ifndef TIMERSET_H
|
|
#define TIMERSET_H
|
|
|
|
#include <ctime>
|
|
#include <vector>
|
|
#include <thread>
|
|
|
|
class Timer;
|
|
|
|
class TimerSet {
|
|
public:
|
|
void pollAllTimers();
|
|
void addATimer(Timer *);
|
|
|
|
private:
|
|
TimerSet();
|
|
std::vector<Timer *> timers;
|
|
std::time_t previousTime;
|
|
std::thread pollingThread;
|
|
|
|
// Meyer's singleton
|
|
public:
|
|
static TimerSet &Instance();
|
|
|
|
private:
|
|
// prevent copying and assignment of the singleton
|
|
TimerSet(const TimerSet &);
|
|
TimerSet &operator=(const TimerSet &);
|
|
|
|
void poll10Hz();
|
|
};
|
|
|
|
#endif
|