CPP-TOOLBOX
Loading...
Searching...
No Matches
FixedFrequencyLoop Class Reference

#include <fixed_frequency_loop.hpp>

Public Member Functions

 FixedFrequencyLoop (double max_update_rate_hz=60)
 
void start (const std::function< void(double)> &rate_limited_func, const std::function< bool()> &termination_condition_func, std::function< void(IterationStats)> loop_stats_function=[](IterationStats is) {})
 a sleep based loop that runs a function at a fixed interval
 
IterationStats get_average_loop_stats ()
 

Public Attributes

double max_update_rate_hz
 
std::deque< IterationStatsiteration_stats_history
 
bool rate_limiter_enabled = true
 
Stopwatch stopwatch
 

Constructor & Destructor Documentation

◆ FixedFrequencyLoop()

FixedFrequencyLoop::FixedFrequencyLoop ( double max_update_rate_hz = 60)
inline

Member Function Documentation

◆ get_average_loop_stats()

IterationStats FixedFrequencyLoop::get_average_loop_stats ( )

◆ start()

void FixedFrequencyLoop::start ( const std::function< void(double)> & rate_limited_func,
const std::function< bool()> & termination_condition_func,
std::function< void(IterationStats)> loop_stats_function = [](IterationStats is) {} )

a sleep based loop that runs a function at a fixed interval

Note
you probably want to run this in its own thread so the sleep doesn't pause your whole program, unless this is your "whole program"
Author
cuppajoeman

Member Data Documentation

◆ iteration_stats_history

std::deque<IterationStats> FixedFrequencyLoop::iteration_stats_history

◆ max_update_rate_hz

double FixedFrequencyLoop::max_update_rate_hz

◆ rate_limiter_enabled

bool FixedFrequencyLoop::rate_limiter_enabled = true

◆ stopwatch

Stopwatch FixedFrequencyLoop::stopwatch

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