Public Member Functions | Private Attributes | List of all members
msp::PeriodicTimer Class Reference

#include <PeriodicTimer.hpp>

Public Member Functions

double getPeriod () const
 getPeriod get period in seconds More...
 
 PeriodicTimer (const std::function< void()> funct, const double period_seconds)
 PeriodicTimer define a periodic timer. More...
 
void setPeriod (const double &period_seconds)
 setPeriod change the update period of timer thread This will stop and restart the thread. More...
 
bool start ()
 start define and start background thread More...
 
bool stop ()
 stop tell thread to stop and wait for end More...
 
 ~PeriodicTimer ()
 PeriodicTimer destructor. More...
 

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
 

Detailed Description

Definition at line 13 of file PeriodicTimer.hpp.

Constructor & Destructor Documentation

msp::PeriodicTimer::PeriodicTimer ( const std::function< void()>  funct,
const double  period_seconds 
)

PeriodicTimer define a periodic timer.

Parameters
functfunction that is called periodically
period_secondsperiod in seconds

Definition at line 5 of file PeriodicTimer.cpp.

msp::PeriodicTimer::~PeriodicTimer ( )
inline

PeriodicTimer destructor.

Definition at line 26 of file PeriodicTimer.hpp.

Member Function Documentation

double msp::PeriodicTimer::getPeriod ( ) const
inline

getPeriod get period in seconds

Returns
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.

Parameters
period_secondsperiod 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.

Member Data Documentation

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.


The documentation for this class was generated from the following files:


msp
Author(s): Christian Rauch
autogenerated on Tue Oct 6 2020 03:39:02