#ifndef CORE_CLOCK_H #define CORE_CLOCK_H #include "data/Array.h" #include "utils/Check.h" namespace Core { struct Clock final { using Nanos = i64; private: static constexpr int BITS = 7; static constexpr int LENGTH = 1 << BITS; int index; Nanos last; Nanos sum; Array time; public: Clock(); // returns true on error and calls the error callback // the first invocation will always return 0 nanos check_return bool update(Nanos& n); float getUpdatesPerSecond() const; // returns true on error and calls the error callback check_return bool wait(Nanos nanos) const; // returns true on error and calls the error callback check_return static bool getNanos(Nanos& n); }; } #endif