Main MRPT website > C++ reference for MRPT 1.5.6
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  */
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;
37  }; // End of class def.
38 
39 } // End of namespace
40 } // End of namespace
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...
Definition: threads.cpp:57
This class implements a high-performance stopwatch.
Definition: CTicTac.h:24
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::utils::CTicTac m_tictac
Definition: CRateTimer.h:36
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.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019