Adapt to new cpputils
This commit is contained in:
parent
ea9d912a16
commit
06b78f1b80
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
4
implementations/caching/cache/PeriodicTask.h
vendored
4
implementations/caching/cache/PeriodicTask.h
vendored
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user