openpilot/common/ratekeeper.h
github-actions[bot] 1f7233cb98 sunnypilot v0.10.1
version: sunnypilot v0.10.1 (staging-tici)
date: 2025-10-13T01:35:37
master commit: 737a6c4236e843034680c951005b38d15815363f
2025-10-13 01:35:37 +00:00

24 lines
520 B
C++

#pragma once
#include <cstdint>
#include <string>
class RateKeeper {
public:
RateKeeper(const std::string &name, float rate, float print_delay_threshold = 0);
~RateKeeper() {}
bool keepTime();
bool monitorTime();
inline uint64_t frame() const { return frame_; }
inline double remaining() const { return remaining_; }
private:
double interval;
double next_frame_time;
double last_monitor_time;
double remaining_ = 0;
float print_delay_threshold = 0;
uint64_t frame_ = 0;
std::string name;
};