Changeset 15 in flair-src for trunk/lib/FlairCore/src/Watchdog.cpp
- Timestamp:
- 04/08/16 15:40:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Watchdog.cpp
r2 r15 20 20 namespace core { 21 21 22 Watchdog::Watchdog(const Object* parent,std::function<void()> _expired,Time _timer):Thread(parent,"watchdog",0),expired(_expired),timer(_timer){ 23 } 22 Watchdog::Watchdog(const Object *parent, std::function<void()> _expired, 23 Time _timer) 24 : Thread(parent, "watchdog", 0), expired(_expired), timer(_timer) {} 24 25 25 26 Watchdog::~Watchdog() { 26 27 27 SafeStop(); 28 Join(); 28 29 } 29 30 30 31 void Watchdog::Touch() { 31 if (IsSuspended()) Resume(); 32 if (IsSuspended()) 33 Resume(); 32 34 } 33 35 34 36 void Watchdog::SetTimer(Time _Timer) { 35 timer=_Timer; Touch(); 37 timer = _Timer; 38 Touch(); 36 39 } 37 40 38 41 void Watchdog::Run() { 39 40 Time current=GetTime();41 Time date=current+timer;42 //Printf("watchdog goes to sleep at %llu, scheduled to wake up at %llu\n",current,date);43 if (!SuspendUntil(date)) {44 expired();45 }42 while (!ToBeStopped()) { 43 Time current = GetTime(); 44 Time date = current + timer; 45 // Printf("watchdog goes to sleep at %llu, scheduled to wake up at 46 // %llu\n",current,date); 47 if (!SuspendUntil(date)) { 48 expired(); 46 49 } 50 } 47 51 }; 48 52
Note:
See TracChangeset
for help on using the changeset viewer.