5#include "flutter/fml/time/time_point.h"
9#include "flutter/fml/build_config.h"
10#include "flutter/fml/logging.h"
12#if defined(OS_FUCHSIA)
13#include <zircon/syscalls.h>
20#if defined(OS_FUCHSIA)
24 return TimePoint(zx_clock_get_monotonic());
35std::atomic<TimePoint::ClockSource> gSteadyClockSource;
38template <
typename Clock,
typename Duration>
40 std::chrono::time_point<Clock, Duration> time_point) {
41 const auto elapsed = time_point.time_since_epoch();
42 return std::chrono::duration_cast<std::chrono::nanoseconds>(elapsed).count();
46 gSteadyClockSource =
source;
50 if (gSteadyClockSource) {
51 return gSteadyClockSource.load()();
53 const int64_t nanos =
NanosSinceEpoch(std::chrono::steady_clock::now());
58 const int64_t nanos =
NanosSinceEpoch(std::chrono::system_clock::now());
TimePoint(*)() ClockSource
static void SetClockSource(ClockSource source)
static TimePoint CurrentWallTime()
constexpr TimePoint()=default
static int64_t NanosSinceEpoch(std::chrono::time_point< Clock, Duration > time_point)
std::chrono::time_point< std::chrono::high_resolution_clock > TimePoint