Clock.cppm 524 B

1234567891011121314151617181920212223
  1. export module Core.Clock;
  2. import Core.Array;
  3. export namespace Core {
  4. struct Clock final {
  5. size_t index;
  6. i64 last;
  7. i64 sum;
  8. Array<i64, 1 << 7> time;
  9. public:
  10. Clock() noexcept;
  11. // the first invocation will always return 0 nanos
  12. i64 update() noexcept;
  13. float getUpdatesPerSecond() const noexcept;
  14. static bool sleepNanos(i64 nanos) noexcept;
  15. static bool sleepMillis(i64 millis) noexcept;
  16. static i64 getNanos() noexcept;
  17. };
  18. }