Added comment explaining why we use boost/thread
This commit is contained in:
parent
52366fb707
commit
1bd64c2f7f
14
implementations/caching/cache/PeriodicTask.cpp
vendored
14
implementations/caching/cache/PeriodicTask.cpp
vendored
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user