Converted PhasedLoop over to monotonic_clock.

Change-Id: Ic8857c4412abb7c19dd3df4aaa5f6c8aa74e9dc6
diff --git a/aos/common/util/phased_loop.h b/aos/common/util/phased_loop.h
index fc0f247..7614ed2 100644
--- a/aos/common/util/phased_loop.h
+++ b/aos/common/util/phased_loop.h
@@ -22,40 +22,47 @@
   //   ...
   //   10000.1s
   // offset must be >= Time::kZero and < interval.
-  PhasedLoop(const Time &interval, const Time &offset = Time::kZero)
+  PhasedLoop(
+      const monotonic_clock::duration interval,
+      const monotonic_clock::duration offset = monotonic_clock::duration(0))
       : interval_(interval), offset_(offset), last_time_(offset) {
-    CHECK_GE(offset, Time::kZero);
-    CHECK_GT(interval, Time::kZero);
+    CHECK_GE(offset, monotonic_clock::duration(0));
+    CHECK_GT(interval, monotonic_clock::duration(0));
     CHECK_LT(offset, interval);
     Reset();
   }
 
   // Resets the count of skipped iterations.
-  // Iterate(now) will return 1 and set sleep_time() to something within
-  // interval of now.
-  void Reset(const Time &now = Time::Now()) { Iterate(now - interval_); }
+  // Iterate(monotonic_now) will return 1 and set sleep_time() to something
+  // within interval of monotonic_now.
+  void Reset(const monotonic_clock::time_point monotonic_now =
+                 monotonic_clock::now()) {
+    Iterate(monotonic_now - interval_);
+  }
 
-  // Calculates the next time to run after now.
+  // Calculates the next time to run after monotonic_now.
   // The result can be retrieved with sleep_time().
   // Returns the number of iterations which have passed (1 if this is called
-  // often enough). This can be < 1 iff now goes backwards between calls.
-  int Iterate(const Time &now = Time::Now());
+  // often enough). This can be < 1 iff monotonic_now goes backwards between
+  // calls.
+  int Iterate(const monotonic_clock::time_point monotonic_now =
+                  monotonic_clock::now());
 
   // Sleeps until the next time and returns the number of iterations which have
   // passed.
   int SleepUntilNext() {
-    const int r = Iterate(Time::Now());
-    SleepUntil(sleep_time());
+    const int r = Iterate(monotonic_clock::now());
+    ::std::this_thread::sleep_until(sleep_time());
     return r;
   }
 
-  const Time &sleep_time() const { return last_time_; }
+  monotonic_clock::time_point sleep_time() const { return last_time_; }
 
  private:
-  const Time interval_, offset_;
+  const monotonic_clock::duration interval_, offset_;
 
   // The time we most recently slept until.
-  Time last_time_ = Time::kZero;
+  monotonic_clock::time_point last_time_ = monotonic_clock::epoch();
 };
 
 }  // namespace time