Improves sensor data queue logging. (#93)

master
Damon Kohler 2016-10-25 11:09:08 +02:00 committed by GitHub
parent 3986ad5328
commit 05adba7c51
1 changed files with 16 additions and 2 deletions

View File

@ -20,6 +20,8 @@
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <memory> #include <memory>
#include <set>
#include <sstream>
#include "cartographer/common/blocking_queue.h" #include "cartographer/common/blocking_queue.h"
#include "cartographer/common/make_unique.h" #include "cartographer/common/make_unique.h"
@ -164,11 +166,23 @@ class OrderedMultiQueue {
// Called when not all necessary queues are filled to dispatch messages. // Called when not all necessary queues are filled to dispatch messages.
void CannotMakeProgress() { void CannotMakeProgress() {
for (auto& entry : queues_) { for (auto& entry : queues_) {
LOG_IF_EVERY_N(WARNING, entry.second.queue.Size() > kMaxQueueSize, 60) if (entry.second.queue.Size() > kMaxQueueSize) {
<< "Queue " << entry.first << " exceeds maximum size."; LOG_EVERY_N(WARNING, 60) << "Queues waiting for data: " << EmptyQueuesDebugString();
return;
}
} }
} }
string EmptyQueuesDebugString() {
std::ostringstream empty_queues;
for (auto& entry : queues_) {
if (entry.second.queue.Size() == 0) {
empty_queues << (empty_queues.tellp() > 0 ? ", " : "") << entry.first;
}
}
return empty_queues.str();
}
// Used to verify that values are dispatched in sorted order. // Used to verify that values are dispatched in sorted order.
common::Time last_dispatched_key_ = common::Time::min(); common::Time last_dispatched_key_ = common::Time::min();