Converted PhasedLoop over to monotonic_clock.
Change-Id: Ic8857c4412abb7c19dd3df4aaa5f6c8aa74e9dc6
diff --git a/aos/common/time.h b/aos/common/time.h
index 40b72b0..ba795a9 100644
--- a/aos/common/time.h
+++ b/aos/common/time.h
@@ -28,8 +28,10 @@
// Returns the epoch (0).
static constexpr monotonic_clock::time_point epoch() {
- return time_point(duration(0));
+ return time_point(zero());
}
+
+ static constexpr monotonic_clock::duration zero() { return duration(0); }
};
namespace time {
@@ -146,8 +148,10 @@
}
// Construct a time representing the period of hertz.
- static constexpr Time FromRate(int hertz) {
- return Time(0, kNSecInSec / hertz);
+ static constexpr ::std::chrono::nanoseconds FromRate(int hertz) {
+ return ::std::chrono::duration_cast<::std::chrono::nanoseconds>(
+ ::std::chrono::seconds(1)) /
+ hertz;
}
// Checks whether or not this time is within amount nanoseconds of other.