1 #if !defined(FLOW_TIMER_H)
6 #include <condition_variable>
23 std::atomic<bool> d_stop_a;
26 typedef std::map<size_t, const std::function<void ()>>
listeners_t;
53 virtual size_t listen(
const std::function<
void ()>& listener)
63 virtual void ignore(
const size_t token)
78 std::chrono::milliseconds d_interval;
80 std::condition_variable d_stopped_cv;
81 std::mutex d_stopped_m;
85 template<
typename Duration>
86 monotonous_timer(
const Duration& interval) : d_interval(std::chrono::duration_cast<std::chrono::milliseconds>(interval)) {}
94 d_stopped_cv.notify_one();
111 std::unique_lock<std::mutex> l_stopped(d_stopped_m);
112 d_stopped_cv.wait_for(l_stopped, d_interval);