Main MRPT website
>
C++ reference for MRPT 1.5.3
mrpt
utils
CRateTimer.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+---------------------------------------------------------------------------+ */
9
#pragma once
10
11
#include <
mrpt/utils/CTicTac.h
>
12
#include <
mrpt/base/link_pragmas.h
>
13
14
namespace
mrpt
15
{
16
namespace
utils
17
{
18
/** A class for calling sleep() in a loop, such that the amount of sleep time will be computed
19
* to make the loop run at the desired rate (in Hz).
20
* \note [New in MRPT 1.5.0]
21
* \ingroup mrpt_base_grp
22
*/
23
class
BASE_IMPEXP
CRateTimer
24
{
25
public
:
26
CRateTimer
(
const
double
rate_hz=1.0);
//!< Ctor: specifies the desired rate (Hz)
27
virtual
~
CRateTimer
();
//!< Dtor
28
29
void
setRate(
const
double
rate_hz);
//!< Changes the object loop rate (Hz)
30
/** Sleeps for some time, such as the return of this method is 1/rate (seconds)
31
* after the return of the previous call.
32
* \return false if the rate could not be achieved ("we are already late"), true if all went right. */
33
bool
sleep
();
34
private
:
35
double
m_rate_hz
;
36
mrpt::utils::CTicTac
m_tictac
;
37
};
// End of class def.
38
39
}
// End of namespace
40
}
// End of namespace
mrpt::system::sleep
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
BASE_IMPEXP
#define BASE_IMPEXP
Definition:
maps/CColouredPointsMap.h:42
mrpt::utils::CTicTac
This class implements a high-performance stopwatch.
Definition:
CTicTac.h:24
CTicTac.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition:
CParticleFilter.h:16
mrpt::utils::CRateTimer::m_tictac
mrpt::utils::CTicTac m_tictac
Definition:
CRateTimer.h:36
link_pragmas.h
mrpt::utils::CRateTimer::m_rate_hz
double m_rate_hz
Definition:
CRateTimer.h:35
mrpt::utils::CRateTimer
A class for calling sleep() in a loop, such that the amount of sleep time will be computed to make th...
Definition:
CRateTimer.h:23
Page generated by
Doxygen 1.8.13
for MRPT 1.5.3 at Sun Nov 26 00:44:48 UTC 2017