21 #ifndef COMMON_IO_TIMEOUTMANAGER_H_
22 #define COMMON_IO_TIMEOUTMANAGER_H_
29 #include "ola/Clock.h"
32 #include "ola/thread/SchedulerInterface.h"
92 return !m_events.empty();
103 static const char K_TIMER_VAR[];
109 : m_interval(interval) {
111 clock->CurrentTime(&now);
112 m_next = now + m_interval;
115 virtual bool Trigger() = 0;
117 void UpdateTime(
const TimeStamp &now) {
118 m_next = now + m_interval;
121 TimeStamp NextTime()
const {
return m_next; }
124 TimeInterval m_interval;
129 class SingleEvent:
public Event {
131 SingleEvent(
const TimeInterval &interval,
134 Event(interval, clock),
138 virtual ~SingleEvent() {
160 class RepeatingEvent:
public Event {
162 RepeatingEvent(
const TimeInterval &interval,
165 Event(interval, clock),
174 return m_closure->Run();
182 bool operator()(Event *e1, Event *e2)
const {
183 return e1->NextTime() > e2->NextTime();
187 typedef std::priority_queue<Event*, std::vector<Event*>, ltevent>
193 event_queue_t m_events;
194 std::set<ola::thread::timeout_id> m_removed_timeouts;
200 #endif // COMMON_IO_TIMEOUTMANAGER_H_