Files
openpilot-meb/common/ratekeeper.h
Dean Lee 061deaa80f common/ratekeeper: change frame() return type from double to uint64_t (#32679)
old-commit-hash: a4f0f6ca3627c9a8a805ec3f20c17d68a710b7f8
2024-06-10 13:37:50 -07: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;
};