#pragma once
+#include <sys/time.h>
+#include <stdint.h>
+
/// @brief return epoch in milliseconds
///
/// @return long long int epoch in milliseconds
private:
float unit_; ///< unit_ - multiplicator to make operation to be in the right unit (milli, micro, nano, etc)
float frequency_; ///< the clock frequency in Hz.
- unsigned long last_tick_; ///< the last time (in milliseconds since startup) that the clock ticked.
+ uint64_t last_tick_; ///< the last time (in microseconds since epoch) that the clock ticked.
time_function_t time_function_; ///< a function returning current time
public:
frequency_clock_t();
- frequency_clock_t(float frequency);
- frequency_clock_t(float frequency, unsigned long last_tick, time_function_t time_function);
+ explicit frequency_clock_t(float frequency);
+ frequency_clock_t(float frequency, uint64_t last_tick, time_function_t time_function);
float get_frequency() const;
+ const struct timeval get_timeval_from_period() const;
- float frequency_to_period();
+ float frequency_to_period() const;
bool started();
time_function_t get_time_function();
bool elapsed(bool stagger);
- void tick();
+ uint64_t get_last_tick() const;
+ void tick(uint64_t timestamp);
};
\ No newline at end of file