Add NodeEventLoopFactory
This lets us create event loops on separate nodes which can't
communicate with each other. Next step is to add a message proxy
between them, then teach the logger to replay onto multiple nodes.
Change-Id: I06b2836365aea13d696535c52a78ca0c862a7b1e
diff --git a/aos/events/event_scheduler.cc b/aos/events/event_scheduler.cc
index b5a530e..57f20ae 100644
--- a/aos/events/event_scheduler.cc
+++ b/aos/events/event_scheduler.cc
@@ -8,7 +8,7 @@
namespace aos {
EventScheduler::Token EventScheduler::Schedule(
- ::aos::monotonic_clock::time_point time, ::std::function<void()> callback) {
+ distributed_clock::time_point time, ::std::function<void()> callback) {
return events_list_.emplace(time, callback);
}
@@ -16,9 +16,9 @@
events_list_.erase(token);
}
-void EventScheduler::RunFor(monotonic_clock::duration duration) {
- const ::aos::monotonic_clock::time_point end_time =
- monotonic_now() + duration;
+void EventScheduler::RunFor(distributed_clock::duration duration) {
+ const distributed_clock::time_point end_time =
+ distributed_now() + duration;
is_running_ = true;
for (std::function<void()> &on_run : on_run_) {
on_run();
@@ -26,7 +26,7 @@
on_run_.clear();
while (!events_list_.empty() && is_running_) {
auto iter = events_list_.begin();
- ::aos::monotonic_clock::time_point next_time = iter->first;
+ distributed_clock::time_point next_time = iter->first;
if (next_time > end_time) {
break;
}
@@ -53,4 +53,11 @@
}
}
+std::ostream &operator<<(std::ostream &stream,
+ const aos::distributed_clock::time_point &now) {
+ // Print it the same way we print a monotonic time. Literally.
+ stream << monotonic_clock::time_point(now.time_since_epoch());
+ return stream;
+}
+
} // namespace aos