#include <PeriodicTimer.hpp>
Public Member Functions | |
double | getPeriod () const |
getPeriod get period in seconds | |
PeriodicTimer (const std::function< void()> funct, const double period_seconds) | |
PeriodicTimer define a periodic timer. | |
void | setPeriod (const double &period_seconds) |
setPeriod change the update period of timer thread This will stop and restart the thread. | |
bool | start () |
start define and start background thread | |
bool | stop () |
stop tell thread to stop and wait for end | |
~PeriodicTimer () | |
PeriodicTimer destructor. | |
Private Attributes | |
std::function< void()> | funct |
std::timed_mutex | mutex_timer |
std::chrono::duration< size_t, std::micro > | period_us |
std::atomic_flag | running_ = ATOMIC_FLAG_INIT |
std::shared_ptr< std::thread > | thread_ptr |
std::chrono::steady_clock::time_point | tstart |
Definition at line 13 of file PeriodicTimer.hpp.
msp::PeriodicTimer::PeriodicTimer | ( | const std::function< void()> | funct, |
const double | period_seconds | ||
) |
PeriodicTimer define a periodic timer.
funct | function that is called periodically |
period_seconds | period in seconds |
Definition at line 5 of file PeriodicTimer.cpp.
msp::PeriodicTimer::~PeriodicTimer | ( | ) | [inline] |
PeriodicTimer destructor.
Definition at line 26 of file PeriodicTimer.hpp.
double msp::PeriodicTimer::getPeriod | ( | ) | const [inline] |
getPeriod get period in seconds
Definition at line 42 of file PeriodicTimer.hpp.
void msp::PeriodicTimer::setPeriod | ( | const double & | period_seconds | ) |
setPeriod change the update period of timer thread This will stop and restart the thread.
period_seconds | period in seconds |
Definition at line 55 of file PeriodicTimer.cpp.
bool msp::PeriodicTimer::start | ( | ) |
start define and start background thread
Definition at line 12 of file PeriodicTimer.cpp.
bool msp::PeriodicTimer::stop | ( | ) |
stop tell thread to stop and wait for end
Definition at line 41 of file PeriodicTimer.cpp.
std::function<void()> msp::PeriodicTimer::funct [private] |
Definition at line 53 of file PeriodicTimer.hpp.
std::timed_mutex msp::PeriodicTimer::mutex_timer [private] |
Definition at line 55 of file PeriodicTimer.hpp.
std::chrono::duration<size_t, std::micro> msp::PeriodicTimer::period_us [private] |
Definition at line 54 of file PeriodicTimer.hpp.
std::atomic_flag msp::PeriodicTimer::running_ = ATOMIC_FLAG_INIT [private] |
Definition at line 58 of file PeriodicTimer.hpp.
std::shared_ptr<std::thread> msp::PeriodicTimer::thread_ptr [private] |
Definition at line 52 of file PeriodicTimer.hpp.
std::chrono::steady_clock::time_point msp::PeriodicTimer::tstart [private] |
Definition at line 56 of file PeriodicTimer.hpp.