-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimerFraschetta.h
30 lines (30 loc) · 974 Bytes
/
TimerFraschetta.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef TimerFraschetta_h
#define TimerFraschetta_h
#include "TimeFraschetta.h"
#include "VirtualStopwatchFraschetta.h"
enum TimerType{NotBlocking,Blocking};
class TimerF:VirtualStopwatchF{
protected: TimeF Period; TimerType TimerT;
public:
using VirtualStopwatchF::Start;
using VirtualStopwatchF::Started;
using VirtualStopwatchF::Stop;
using VirtualStopwatchF::ElapsedTime;
void SetPeriodAndTimeUnit(uint64_t Period,UnitOfTime Unit){
SetUnitOfTime(Unit);
this->Period = TimeF(Period,Unit);
this->Period.ConvertTo(Microseconds);
}
void SetTimerType(TimerType Type){TimerT=Type;}
bool Stopped(){
if(VirtualStopwatchF::Active){
if(TimerT==NotBlocking){if(ElapsedTime()>=Period){VirtualStopwatchF::Stop(); return 1;} return 0;}
else{Wait(Period); return 1;}
}
return 0;
}
TimerF(uint64_t Period,UnitOfTime Unit=Seconds,TimerType Type=NotBlocking):VirtualStopwatchF(Unit)
{SetPeriodAndTimeUnit(Period,Unit); SetTimerType(Type);}
TimerF(){}
};
#endif