Class DeadlineTimer
Defined in File deadline_timer.hpp
Class Documentation
-
class DeadlineTimer
This offers the deadline timer functionality. It has user convenient methods to reset the timer [by default it uses the intialized duration], reset timer to a customized duration, check if the timer is active and user can also get to know about the remaining time before the timer goes off.
iox::cxx::DeadlineTimer deadlineTimer(1000_ms); // to check if the timer is active if( deadlineTimer.hasExpired()){ ... } // to reset the timer and start again with the same duration deadlineTimer.reset();
Public Functions
-
explicit DeadlineTimer(const iox::units::Duration timeToWait) noexcept
Constructor.
- Parameters:
timeToWait – [in] duration until the timer expires
-
bool hasExpired() const noexcept
Checks if the timer has expired compared to its absolute end time.
- Returns:
false if the timer is still active and true if it is expired
-
void reset() noexcept
reinitializes the ending time for the timer. The absolute end time is calculated by adding time to wait to the current time.
-
void reset(const iox::units::Duration timeToWait) noexcept
reinitializes the ending time for the timer to the given new time to wait. The absolute end time is calculated by adding new time to wait to the current time.
- Parameters:
timeToWait – [in] duration until the timer expires. This value overwrites the earlier value which was set during the timer creation.
-
explicit DeadlineTimer(const iox::units::Duration timeToWait) noexcept