50 uint64_t serial {++Timer::nextSerial};
100 int repeatCount = -1);
114 bool shift(std::chrono::milliseconds interval)
116 if (m_repeatCount == 0)
121 if (m_repeatCount > 0)
123 m_id.when = m_id.when + interval;
129 m_id.when = m_id.when + interval;
138 return m_repeatInterval;
146 return m_repeatCount;
157 std::chrono::milliseconds m_repeatInterval;
158 int m_repeatCount {0};
164 using Event = std::shared_ptr<EventData>;
216 mutable std::mutex m_mutex;
217 std::set<Event> m_events;
219 static std::atomic<uint64_t> nextSerial;
220 static std::mutex timerThreadMutex;
221 static std::shared_ptr<TimerThread> timerThread;
223 std::set<Timer::Event> moveOutEvents();
225 static void checkTimerThreadRunning();
Definition: DateTime.h:86
bool shift(std::chrono::milliseconds interval)
Definition: Timer.h:114
EventData(const DateTime ×tamp, const Callback &eventCallback, std::chrono::milliseconds repeatEvery, int repeatCount=-1)
int getRepeatCount() const
Definition: Timer.h:144
EventData & operator=(const EventData &other)=delete
EventData(const EventData &other)=delete
const std::chrono::milliseconds & getInterval() const
Definition: Timer.h:136
const EventId & getId() const
const DateTime & getWhen() const
Definition: Timer.h:105
std::function< void()> Callback
Definition: Timer.h:73
Event fireAt(const DateTime ×tamp, const EventData::Callback &eventCallback)
std::shared_ptr< EventData > Event
Definition: Timer.h:164
Timer(const Timer &other)=delete
void unlink(const Event &event)
Remove event from this timer.
Event repeat(std::chrono::milliseconds interval, const EventData::Callback &eventCallback, int repeatCount=-1)
void cancel(const Event &event)
DateTime when
Execution date and time.
Definition: Timer.h:51
EventId(const DateTime &when)