hlswmaster-ng/timerservice.h

55 lines
840 B
C
Raw Normal View History

2006-02-02 16:55:44 +01:00
#ifndef _TIMERSERVICE_H_
#define _TIMERSERVICE_H_
#include "mutex.h"
class Command {
public:
virtual ~Command() {};
virtual void execute() =0;
protected:
Command() {};
};
class Timer {
friend class TimerService;
public:
Timer(Command* cmd, unsigned int timeval);
~Timer();
protected:
Timer(const Timer& te);
Timer& operator=(const Timer& te);
private:
Timer* next;
Command* cmd;
int timeval;
long timeout;
};
class TimerService {
public:
static void registerTimer(Timer* te);
static void checkTimers();
protected:
TimerService(const TimerService& ts);
TimerService& operator=(const TimerService& ts);
private:
TimerService() {}
~TimerService();
static TimerService* getInstance();
void addTimer(Timer* te, bool trigger);
void checkTimeouts();
Timer* firstTimer;
Mutex mutex;
};
#endif // _TIMERSERVICE_H_