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() {
try {
boost::this_thread::sleep_for(_interval);
_task();
} catch (const std::exception &e) {
LOG(ERROR) << "PeriodicTask crashed: " << e.what();
throw;
} catch (...) {
LOG(ERROR) << "PeriodicTask crashed";
throw;
}
//Has to be boost::this_thread::sleep_for and not std::this_thread::sleep_for, because it has to be interruptible.
//LoopThread will interrupt this method if it has to be restarted.
boost::this_thread::sleep_for(_interval);
_task();
}
}