Handle log files not starting at the same time.
The monotonic clocks were assumed to be in sync. That isn't realistic.
This assumption leaked into how we kept the queues primed, and how the
event loop was initialized.
This isn't enough to actually replay in sync. We are assuming that the
realtime clocks are in sync and the monotonic clocks don't drift from
each other. That'll be good enough to get started, but not for long.
Change-Id: Ic18e31598f1a76edee0b0d5a2d7936deee1fbfec
diff --git a/aos/events/simulated_event_loop.h b/aos/events/simulated_event_loop.h
index 21b241a..9dd3d1f 100644
--- a/aos/events/simulated_event_loop.h
+++ b/aos/events/simulated_event_loop.h
@@ -154,6 +154,14 @@
inline distributed_clock::time_point ToDistributedClock(
monotonic_clock::time_point time) const;
+ // Note: use this very very carefully. It can cause massive problems. This
+ // needs to go away as we properly handle time drifting between nodes.
+ void SetMonotonicNow(monotonic_clock::time_point monotonic_now) {
+ monotonic_clock::duration offset = (monotonic_now - this->monotonic_now());
+ monotonic_offset_ += offset;
+ realtime_offset_ -= offset;
+ }
+
private:
friend class SimulatedEventLoopFactory;
NodeEventLoopFactory(