26 #include <IDGenerator.h>
67 int add(
const std::chrono::milliseconds& timeout,
bool oneShot,
68 const std::function<
bool()>& func);
75 struct timespec
calcAbsTime(const struct timespec& now,
76 const std::chrono::milliseconds& timeout)
const;
84 struct timespec expiry;
85 std::function<bool()> func;
86 std::chrono::milliseconds timeout;
88 bool isLessThanOrEqualTo(
const struct timespec& rhs)
const
90 return (expiry.tv_sec < rhs.tv_sec) ||
91 ((expiry.tv_sec == rhs.tv_sec) &&
92 (expiry.tv_nsec <= rhs.tv_nsec));
102 return (a.expiry.tv_sec < b.expiry.tv_sec) ||
103 ((a.expiry.tv_sec == b.expiry.tv_sec) &&
104 (a.expiry.tv_nsec < b.expiry.tv_nsec));
108 std::multiset<TimerEntry, TimerEntryCompare> mTimersQueue;
111 std::recursive_mutex mLock;
Definition: DobbyTimer.h:98
Utility object that can be used to register a callback function to execute in the future.
Definition: DobbyTimer.h:58
void stop()
Stops the poll loop thread and cancels all timers.
Definition: DobbyTimer.cpp:86
struct timespec calcAbsTime(const struct timespec &now, const std::chrono::milliseconds &timeout) const
Calculates the a new time value based on the time now and the supplied millisecond offset.
Definition: DobbyTimer.cpp:119
void updateTimerFd() const
Writes the item on the head of the expiry queue into the timerfd for the next wake-up time.
Definition: DobbyTimer.cpp:272
int add(const std::chrono::milliseconds &timeout, bool oneShot, const std::function< bool()> &func)
Adds a new timer to the timer queue.
Definition: DobbyTimer.cpp:153
void timerThread()
The thread function that runs the timer poll loop.
Definition: DobbyTimer.cpp:306
bool remove(int timerId)
Removes the given timer from the timer queue.
Definition: DobbyTimer.cpp:215
Definition: DobbyTimer.h:81