Adapt to new cpputils

This commit is contained in:
Sebastian Messmer 2015-11-12 13:07:59 -08:00
parent ea9d912a16
commit 06b78f1b80
2 changed files with 4 additions and 3 deletions

View File

@ -15,11 +15,12 @@ PeriodicTask::PeriodicTask(function<void ()> task, double intervalSec) :
_thread.start();
}
void PeriodicTask::_loopIteration() {
bool PeriodicTask::_loopIteration() {
//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();
return true; // Run another iteration (don't terminate thread)
}
}

View File

@ -3,7 +3,7 @@
#define MESSMER_BLOCKSTORE_IMPLEMENTATIONS_CACHING_CACHE_PERIODICTASK_H_
#include <functional>
#include <messmer/cpp-utils/random/LoopThread.h>
#include <messmer/cpp-utils/thread/LoopThread.h>
#include <boost/chrono.hpp>
namespace blockstore {
@ -14,7 +14,7 @@ public:
PeriodicTask(std::function<void ()> task, double intervalSec);
private:
void _loopIteration();
bool _loopIteration();
std::function<void()> _task;
boost::chrono::nanoseconds _interval;