Sort the RemoteMessageSender queue
Timestamps aren't guarenteed to come in order. Sort them so we wake up
and send the replies in the correct order
Change-Id: I3ecdda42413f8c994f51bf39b7dbbe334617d178
diff --git a/aos/events/logging/logger.cc b/aos/events/logging/logger.cc
index eb7221d..52e148b 100644
--- a/aos/events/logging/logger.cc
+++ b/aos/events/logging/logger.cc
@@ -2034,8 +2034,16 @@
<< ": Unsupported mix of timestamps and no timestamps.";
sender_.Send(std::move(remote_message));
} else {
- remote_timestamps_.emplace_back(std::move(remote_message),
- monotonic_timestamp_time);
+ remote_timestamps_.emplace(
+ std::upper_bound(
+ remote_timestamps_.begin(), remote_timestamps_.end(),
+ monotonic_timestamp_time,
+ [](const aos::monotonic_clock::time_point monotonic_timestamp_time,
+ const Timestamp ×tamp) {
+ return monotonic_timestamp_time <
+ timestamp.monotonic_timestamp_time;
+ }),
+ std::move(remote_message), monotonic_timestamp_time);
ScheduleTimestamp();
}
}