Push managing the message queue into TimestampMapper
We want to be able to have multinode_timestamp_filter trigger more data
to be queued. This will let us manage startup much better when Logger
tries to compute what is happening at the start time (and we aren't
guaranteed to have queued that far ahead). We can then have
multinode_timestamp_filter grow the queue as timestamps are being
pulled.
Move feeding timetamps into the noncausal filter from LogReader into the
TimestampMapper callback. This is now registered from inside the
multinode timestamp filter directly. This also removes the need for
the queue inside LogReader to hold the buffered times.
Change-Id: I054518d9be41d2a6560c45bc3a68a23c8e31347a
diff --git a/aos/events/logging/logfile_utils.cc b/aos/events/logging/logfile_utils.cc
index 3850b44..8f0e938 100644
--- a/aos/events/logging/logfile_utils.cc
+++ b/aos/events/logging/logfile_utils.cc
@@ -884,6 +884,30 @@
}
}
+void TimestampMapper::QueueFor(chrono::nanoseconds time_estimation_buffer) {
+ // Make sure we have something queued first. This makes the end time
+ // calculation simpler, and is typically what folks want regardless.
+ if (matched_messages_.empty()) {
+ if (!QueueMatched()) {
+ return;
+ }
+ }
+
+ const aos::monotonic_clock::time_point end_queue_time =
+ std::max(monotonic_start_time(),
+ matched_messages_.front().monotonic_event_time) +
+ time_estimation_buffer;
+
+ // Place sorted messages on the list until we have
+ // --time_estimation_buffer_seconds seconds queued up (but queue at least
+ // until the log starts).
+ while (end_queue_time >= last_message_time_) {
+ if (!QueueMatched()) {
+ return;
+ }
+ }
+}
+
void TimestampMapper::PopFront() {
CHECK(first_message_ != FirstMessage::kNeedsUpdate);
first_message_ = FirstMessage::kNeedsUpdate;