Added comment explaining why we use boost/thread

This commit is contained in:
Sebastian Messmer 2015-10-28 15:30:59 +01:00
parent 52366fb707
commit 1bd64c2f7f

View File

@ -16,16 +16,10 @@ PeriodicTask::PeriodicTask(function<void ()> task, double intervalSec) :
} }
void PeriodicTask::_loopIteration() { void PeriodicTask::_loopIteration() {
try { //Has to be boost::this_thread::sleep_for and not std::this_thread::sleep_for, because it has to be interruptible.
boost::this_thread::sleep_for(_interval); //LoopThread will interrupt this method if it has to be restarted.
_task(); boost::this_thread::sleep_for(_interval);
} catch (const std::exception &e) { _task();
LOG(ERROR) << "PeriodicTask crashed: " << e.what();
throw;
} catch (...) {
LOG(ERROR) << "PeriodicTask crashed";
throw;
}
} }
} }