iceoryx_hoofs 2.0.3
Public Member Functions | List of all members
iox::cxx::DeadlineTimer Class Reference

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. More...

#include <iceoryx_hoofs/cxx/deadline_timer.hpp>

Public Member Functions

 DeadlineTimer (const iox::units::Duration timeToWait) noexcept
 Constructor. More...
 
bool hasExpired () const noexcept
 Checks if the timer has expired compared to its absolute end time. More...
 
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. More...
 
iox::units::Duration remainingTime () const noexcept
 calculates the remaining time before the timer goes off More...
 

Detailed Description

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();
This offers the deadline timer functionality. It has user convenient methods to reset the timer [by d...
Definition: deadline_timer.hpp:44

Constructor & Destructor Documentation

◆ DeadlineTimer()

iox::cxx::DeadlineTimer::DeadlineTimer ( const iox::units::Duration  timeToWait)
explicitnoexcept

Constructor.

Parameters
[in]timeToWaitduration until the timer expires

Member Function Documentation

◆ hasExpired()

bool iox::cxx::DeadlineTimer::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

◆ remainingTime()

iox::units::Duration iox::cxx::DeadlineTimer::remainingTime ( ) const
noexcept

calculates the remaining time before the timer goes off

Returns
the time duration before the timer expires

◆ reset()

void iox::cxx::DeadlineTimer::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
[in]timeToWaitduration until the timer expires. This value overwrites the earlier value which was set during the timer creation.

The documentation for this class was generated from the following file: