| 12345678910111213141516171819202122232425262728293031 |
- #ifndef UTIL_TIMER_H
- #define UTIL_TIMER_H
- #include <atomic>
- #include <functional>
- #include <thread>
- namespace PresenceDetection {
- namespace Util {
- class Timer
- {
- public:
- Timer();
- ~Timer();
- void Start(int interval, std::function<void(void)> func);
- void Stop();
- bool IsRunning() const noexcept;
- void Wait();
- private:
- std::atomic<bool> m_run;
- std::thread m_thread;
- };
- } // namespace Util
- } // namespace PresenceDetection
- #endif // UTIL_TIMER_H
|