BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
PeriodicRunner.h
1 #pragma once
2 
3 #include <functional>
4 
5 #include <Poco/Timer.h>
6 #include <Poco/Timespan.h>
7 
8 #include "util/Loggable.h"
9 
10 namespace BeeeOn {
11 
18 class PeriodicRunner : Poco::Timer, protected Loggable {
19 public:
20  typedef std::function<void()> Callback;
21 
23  virtual ~PeriodicRunner();
24 
28  void start(const Callback &callback);
29 
33  void stop();
34 
38  void setInterval(const Poco::Timespan &interval);
39 
40 private:
44  void onStart(Poco::Timer &timer);
45 
46 private:
47  Poco::TimerCallback<PeriodicRunner> m_invoke;
48  Callback m_callback;
49  Poco::Timespan m_interval;
50 };
51 
52 }
void setInterval(const Poco::Timespan &interval)
Definition: PeriodicRunner.cpp:32
void stop()
Definition: PeriodicRunner.cpp:27
void start(const Callback &callback)
Definition: PeriodicRunner.cpp:18
Executes some function periodacally based on the given interval.
Definition: PeriodicRunner.h:18
Definition: Loggable.h:19