From 1bd64c2f7ffc6409d94cdae5c5caae373464a6b6 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Wed, 28 Oct 2015 15:30:59 +0100 Subject: [PATCH] Added comment explaining why we use boost/thread --- implementations/caching/cache/PeriodicTask.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/implementations/caching/cache/PeriodicTask.cpp b/implementations/caching/cache/PeriodicTask.cpp index d3baf339..a8e8abfc 100644 --- a/implementations/caching/cache/PeriodicTask.cpp +++ b/implementations/caching/cache/PeriodicTask.cpp @@ -16,16 +16,10 @@ PeriodicTask::PeriodicTask(function 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(); } }