Main MRPT website > C++ reference for MRPT 1.5.3
List of all members | Public Member Functions | Private Attributes
mrpt::utils::CRateTimer Class Reference

Detailed Description

A class for calling sleep() in a loop, such that the amount of sleep time will be computed to make the loop run at the desired rate (in Hz).

Note
[New in MRPT 1.5.0]

Definition at line 23 of file CRateTimer.h.

#include <mrpt/utils/CRateTimer.h>

Public Member Functions

 CRateTimer (const double rate_hz=1.0)
 Ctor: specifies the desired rate (Hz) More...
 
virtual ~CRateTimer ()
 Dtor. More...
 
void setRate (const double rate_hz)
 Changes the object loop rate (Hz) More...
 
bool sleep ()
 Sleeps for some time, such as the return of this method is 1/rate (seconds) after the return of the previous call. More...
 

Private Attributes

double m_rate_hz
 
mrpt::utils::CTicTac m_tictac
 

Constructor & Destructor Documentation

◆ CRateTimer()

mrpt::utils::CRateTimer::CRateTimer ( const double  rate_hz = 1.0)

Ctor: specifies the desired rate (Hz)

◆ ~CRateTimer()

virtual mrpt::utils::CRateTimer::~CRateTimer ( )
virtual

Dtor.

Member Function Documentation

◆ setRate()

void mrpt::utils::CRateTimer::setRate ( const double  rate_hz)

Changes the object loop rate (Hz)

◆ sleep()

bool mrpt::utils::CRateTimer::sleep ( )

Sleeps for some time, such as the return of this method is 1/rate (seconds) after the return of the previous call.

Returns
false if the rate could not be achieved ("we are already late"), true if all went right.

Member Data Documentation

◆ m_rate_hz

double mrpt::utils::CRateTimer::m_rate_hz
private

Definition at line 35 of file CRateTimer.h.

◆ m_tictac

mrpt::utils::CTicTac mrpt::utils::CRateTimer::m_tictac
private

Definition at line 36 of file CRateTimer.h.




Page generated by Doxygen 1.8.13 for MRPT 1.5.3 at Tue Aug 22 01:03:35 UTC 2017