Newer
Older
Import / applications / HighwayDash / ports / Framework / Time.h
@John Ryland John Ryland on 22 Dec 2020 763 bytes import NUC files
#ifndef TIME_H
#define TIME_H


#include <chrono>
#include <stdint.h>


/*
struct TimePoint
{
  uint64_t nanoSecondsFromEpoc; 
  static const TimePoint& getCurrentTime();
};


struct Duration
{
  uint64_t nanoSeconds;
};

TimePoint operator+=(TimePoint, Duration);
Duration operator-(TimePoint, TimePoint);

*/

typedef std::chrono::time_point<std::chrono::high_resolution_clock, std::nano>   TimePoint;
typedef std::chrono::duration<uint64_t, std::nano>                               Duration;


TimePoint Now()
{
  // time_point_sec = std::chrono::time_point_cast<Sec>(time_point_ms);
  return std::chrono::high_resolution_clock::now();
}

void MilliSecondSleep(uint32_t ms)
{
  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}


#endif // TIME_H