Upgraded the rest of Time.
Change-Id: I0ee083837e51d8f74a798b7ba14a3b6bb3859f35
diff --git a/aos/vision/events/epoll_events.cc b/aos/vision/events/epoll_events.cc
index 56b22e2..aaecdbf 100644
--- a/aos/vision/events/epoll_events.cc
+++ b/aos/vision/events/epoll_events.cc
@@ -57,10 +57,10 @@
private:
// Calculates the new timeout value to pass to epoll_wait.
int CalculateTimeout() {
- const ::aos::time::Time now = ::aos::time::Time::Now();
+ const monotonic_clock::time_point monotonic_now = monotonic_clock::now();
int r = -1;
for (EpollWait *c : waits_) {
- const int new_timeout = c->Recalculate(now);
+ const int new_timeout = c->Recalculate(monotonic_now);
if (new_timeout >= 0) {
if (r < 0 || new_timeout < r) {
r = new_timeout;
diff --git a/aos/vision/events/epoll_events.h b/aos/vision/events/epoll_events.h
index f032e61..1cb6842 100644
--- a/aos/vision/events/epoll_events.h
+++ b/aos/vision/events/epoll_events.h
@@ -25,7 +25,7 @@
// Sets this wait to end at new_time.
// A negative new_time disables this wait.
- void SetTime(const ::aos::time::Time &new_time) { time_ = new_time; }
+ void SetTime(const monotonic_clock::time_point new_time) { time_ = new_time; }
private:
// Calculates how long to wait starting at now and calls Done() if
@@ -33,21 +33,23 @@
// Returns the number of milliseconds from now that this event will expire in.
// Returns -1 if this wait is never going to expire.
// Returns INT_MAX if this wait expires in longer than that.
- int Recalculate(const ::aos::time::Time &now) {
- if (time_ < ::aos::time::Time::kZero) return -1;
+ int Recalculate(const monotonic_clock::time_point now) {
+ if (time_ < monotonic_clock::epoch()) return -1;
if (time_ <= now) {
Done();
- time_ = ::aos::time::Time(-1, 0);
+ time_ = monotonic_clock::time_point(::std::chrono::seconds(-1));
return -1;
}
- if (time_ - now > ::aos::time::Time::InMS(INT_MAX)) {
+ if (time_ - now > ::std::chrono::milliseconds(INT_MAX)) {
return INT_MAX;
} else {
- return (time_ - now).ToMSec();
+ return ::std::chrono::duration_cast<::std::chrono::milliseconds>(time_ -
+ now)
+ .count();
}
}
- ::aos::time::Time time_ = ::aos::time::Time::kZero;
+ ::aos::monotonic_clock::time_point time_ = ::aos::monotonic_clock::epoch();
friend class EpollLoop;
};