Changeset 15 in flair-src for trunk/lib/FlairCore/src/Watchdog.cpp


Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (6 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Watchdog.cpp

    r2 r15  
    2020namespace core {
    2121
    22 Watchdog::Watchdog(const Object* parent,std::function<void()> _expired,Time _timer):Thread(parent,"watchdog",0),expired(_expired),timer(_timer){
    23 }
     22Watchdog::Watchdog(const Object *parent, std::function<void()> _expired,
     23                   Time _timer)
     24    : Thread(parent, "watchdog", 0), expired(_expired), timer(_timer) {}
    2425
    2526Watchdog::~Watchdog() {
    26     SafeStop();
    27     Join();
     27  SafeStop();
     28  Join();
    2829}
    2930
    3031void Watchdog::Touch() {
    31     if (IsSuspended()) Resume();
     32  if (IsSuspended())
     33    Resume();
    3234}
    3335
    3436void Watchdog::SetTimer(Time _Timer) {
    35     timer=_Timer; Touch();
     37  timer = _Timer;
     38  Touch();
    3639}
    3740
    3841void Watchdog::Run() {
    39     while (!ToBeStopped()) {
    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();
    4649    }
     50  }
    4751};
    4852
Note: See TracChangeset for help on using the changeset viewer.