23 #ifndef AI_IPC_DBUSTIMEOUTS_H
24 #define AI_IPC_DBUSTIMEOUTS_H
31 #include <dbus/dbus.h>
68 static dbus_bool_t addTimeOutCb(DBusTimeout *timeout,
void *userData);
69 static void toggleTimeOutCb(DBusTimeout *timeout,
void *userData);
70 static void removeTimeOutCb(DBusTimeout *timeout,
void *userData);
77 struct timespec
calcAbsTime(const struct timespec& base,
78 int milliseconds)
const;
82 inline bool hasExpired(
const struct timespec& expiryTime,
83 const struct timespec& currentTime)
const;
87 DBusConnection*
const mDbusConnection;
88 bool mWithinEventHandler;
93 struct timespec expiry;
98 return (expiry.tv_sec < rhs.expiry.tv_sec) ||
99 ((expiry.tv_sec == rhs.expiry.tv_sec) &&
100 (expiry.tv_nsec < rhs.expiry.tv_nsec));
105 std::list<TimeoutEntry> mTimeouts;
107 #if (AI_BUILD_TYPE == AI_DEBUG)
109 const std::thread::id mExpectedThreadId;
Object that manages the timeouts for a given dbus connection.
Definition: DbusTimeouts.h:58
struct timespec calcAbsTime(const struct timespec &base, int milliseconds) const
Calculates a new time value based on the time now and the supplied millisecond offset.
Definition: DbusTimeouts.cpp:214
int fd() const
Returns the timerfd that the dispatcher should poll on.
Definition: DbusTimeouts.cpp:106
void processEvent(unsigned int pollEvents)
Called when something has happened on the timerfd event loop.
Definition: DbusTimeouts.cpp:121
dbus_bool_t addTimeOut(DBusTimeout *timeout)
Adds the given timeout to the timerfd to poll on.
Definition: DbusTimeouts.cpp:306
bool hasExpired(const struct timespec &expiryTime, const struct timespec ¤tTime) const
Utility function that simply checks if a timespec is after or equal to another timespec.
Definition: DbusTimeouts.cpp:256
void toggleTimeOut(DBusTimeout *timeout)
Toggles the enable / disable state of a timeout.
Definition: DbusTimeouts.cpp:436
void updateTimerFd() const
Writes the item on the head of the expiry queue into the timerfd for the next wake-up time.
Definition: DbusTimeouts.cpp:273
void removeTimeOut(DBusTimeout *timeout)
Removes the timeout from the timerfd.
Definition: DbusTimeouts.cpp:379
Definition: DbusTimeouts.h:92