BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Occasionally.h
1 #pragma once
2 
3 #include <functional>
4 #include <Poco/Timestamp.h>
5 #include <Poco/Mutex.h>
6 
7 namespace BeeeOn {
8 
15 class Occasionally {
16 public:
17  Occasionally(unsigned int max = 1000,
18  const Poco::Timestamp::TimeDiff delayMax = 0);
19 
20  void execute(const std::function<void ()> &func);
21 
22 private:
23  unsigned int m_count;
24  unsigned int m_max;
25  Poco::Timestamp m_lastTimestamp;
26  Poco::Timestamp::TimeDiff m_delayMax;
27  Poco::FastMutex m_lock;
28 };
29 
30 }
Definition: Occasionally.h:15