File spinner.hpp¶
Tools for maintaining the timing on a while loop.
- Author
Maximilien Naveau (maximilien.naveau@gmail.com) license License BSD-3-Clause
- Copyright
Copyright (c) 2019, New York University and Max Planck Gesellschaft.
- Date
2019-05-22
-
namespace
real_time_tools
-
class
Spinner
- #include <spinner.hpp>
Class to have threads / loops running at a desired frequency.
Public Functions
-
Spinner
()
-
inline void
set_period
(double period) set_period sets the period of the loop in !!seconds!!
- Parameters:
period – in seconds.
-
inline void
set_frequency
(double frequency) Set the frequency of the loop [Hz].
- Parameters:
frequency –
-
void
initialize
() To be called at the beginning of the loop if the spinner is not created just before.
-
void
spin
() spin waits for the time such that successive calls to spin will result in spin being called at the desired frequency
-
double
predict_sleeping_time
() Predict the time the current thread is going to sleep.
Private Members
-
double
period_sec_
period_sec_ is the period of the loop in seconds
-
double
next_date_sec_
next_date_sec_ is the date when the loop needs to wake up.
-
-
class