Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
fml::TimePoint Class Reference

#include <time_point.h>

Public Types

using ClockSource = TimePoint(*)()
 

Public Member Functions

constexpr TimePoint ()=default
 
TimeDelta ToEpochDelta () const
 
TimeDelta operator- (TimePoint other) const
 
TimePoint operator+ (TimeDelta duration) const
 
TimePoint operator- (TimeDelta duration) const
 
bool operator== (TimePoint other) const
 
bool operator!= (TimePoint other) const
 
bool operator< (TimePoint other) const
 
bool operator<= (TimePoint other) const
 
bool operator> (TimePoint other) const
 
bool operator>= (TimePoint other) const
 

Static Public Member Functions

static void SetClockSource (ClockSource source)
 
static TimePoint Now ()
 
static TimePoint CurrentWallTime ()
 
static constexpr TimePoint Min ()
 
static constexpr TimePoint Max ()
 
static constexpr TimePoint FromEpochDelta (TimeDelta ticks)
 
static constexpr TimePoint FromTicks (int64_t ticks)
 

Detailed Description

Definition at line 22 of file time_point.h.

Member Typedef Documentation

◆ ClockSource

Definition at line 24 of file time_point.h.

Constructor & Destructor Documentation

◆ TimePoint()

constexpr fml::TimePoint::TimePoint ( )
constexprdefault

Member Function Documentation

◆ CurrentWallTime()

TimePoint fml::TimePoint::CurrentWallTime ( )
static

Definition at line 57 of file time_point.cc.

57 {
58 const int64_t nanos = NanosSinceEpoch(std::chrono::system_clock::now());
59 return TimePoint(nanos);
60}
constexpr TimePoint()=default
static int64_t NanosSinceEpoch(std::chrono::time_point< Clock, Duration > time_point)
Definition: time_point.cc:39

◆ FromEpochDelta()

static constexpr TimePoint fml::TimePoint::FromEpochDelta ( TimeDelta  ticks)
inlinestaticconstexpr

Definition at line 43 of file time_point.h.

43 {
44 return TimePoint(ticks.ToNanoseconds());
45 }

◆ FromTicks()

static constexpr TimePoint fml::TimePoint::FromTicks ( int64_t  ticks)
inlinestaticconstexpr

Definition at line 48 of file time_point.h.

48 {
49 return TimePoint(ticks);
50 }

◆ Max()

static constexpr TimePoint fml::TimePoint::Max ( )
inlinestaticconstexpr

Definition at line 39 of file time_point.h.

39 {
41 }
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ Min()

static constexpr TimePoint fml::TimePoint::Min ( )
inlinestaticconstexpr

Definition at line 35 of file time_point.h.

35 {
37 }
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ Now()

TimePoint fml::TimePoint::Now ( )
static

Definition at line 49 of file time_point.cc.

49 {
50 if (gSteadyClockSource) {
51 return gSteadyClockSource.load()();
52 }
53 const int64_t nanos = NanosSinceEpoch(std::chrono::steady_clock::now());
54 return TimePoint(nanos);
55}

◆ operator!=()

bool fml::TimePoint::operator!= ( TimePoint  other) const
inline

Definition at line 67 of file time_point.h.

67{ return ticks_ != other.ticks_; }

◆ operator+()

TimePoint fml::TimePoint::operator+ ( TimeDelta  duration) const
inline

Definition at line 59 of file time_point.h.

59 {
60 return TimePoint(ticks_ + duration.ToNanoseconds());
61 }
double duration
Definition: examples.cpp:30

◆ operator-() [1/2]

TimePoint fml::TimePoint::operator- ( TimeDelta  duration) const
inline

Definition at line 62 of file time_point.h.

62 {
63 return TimePoint(ticks_ - duration.ToNanoseconds());
64 }

◆ operator-() [2/2]

TimeDelta fml::TimePoint::operator- ( TimePoint  other) const
inline

Definition at line 55 of file time_point.h.

55 {
56 return TimeDelta::FromNanoseconds(ticks_ - other.ticks_);
57 }
static constexpr TimeDelta FromNanoseconds(int64_t nanos)
Definition: time_delta.h:40

◆ operator<()

bool fml::TimePoint::operator< ( TimePoint  other) const
inline

Definition at line 68 of file time_point.h.

68{ return ticks_ < other.ticks_; }

◆ operator<=()

bool fml::TimePoint::operator<= ( TimePoint  other) const
inline

Definition at line 69 of file time_point.h.

69{ return ticks_ <= other.ticks_; }

◆ operator==()

bool fml::TimePoint::operator== ( TimePoint  other) const
inline

Definition at line 66 of file time_point.h.

66{ return ticks_ == other.ticks_; }

◆ operator>()

bool fml::TimePoint::operator> ( TimePoint  other) const
inline

Definition at line 70 of file time_point.h.

70{ return ticks_ > other.ticks_; }

◆ operator>=()

bool fml::TimePoint::operator>= ( TimePoint  other) const
inline

Definition at line 71 of file time_point.h.

71{ return ticks_ >= other.ticks_; }

◆ SetClockSource()

void fml::TimePoint::SetClockSource ( ClockSource  source)
static

Definition at line 45 of file time_point.cc.

45 {
46 gSteadyClockSource = source;
47}
SkBitmap source
Definition: examples.cpp:28

◆ ToEpochDelta()

TimeDelta fml::TimePoint::ToEpochDelta ( ) const
inline

Definition at line 52 of file time_point.h.

52{ return TimeDelta::FromNanoseconds(ticks_); }

The documentation for this class was generated from the following files: