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() {
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user