From 224b068fe99c59d08c05ab09d6964f1bc4a560b0 Mon Sep 17 00:00:00 2001 From: Damon Kohler Date: Thu, 27 Oct 2016 11:45:27 +0200 Subject: [PATCH] CHECKs that all queues are finished on destruction. (#106) --- cartographer/sensor/ordered_multi_queue.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cartographer/sensor/ordered_multi_queue.h b/cartographer/sensor/ordered_multi_queue.h index fc4e313..321c84b 100644 --- a/cartographer/sensor/ordered_multi_queue.h +++ b/cartographer/sensor/ordered_multi_queue.h @@ -50,15 +50,19 @@ inline std::ostream& operator<<(std::ostream& out, const QueueKey& key) { } // Maintains multiple queues of sorted sensor data and dispatches it in merge -// sorted order. This class is thread-compatible. +// sorted order. It will wait to see at least one value for each unfinished queue before +// dispatching the next time ordered value across all queues. This class is thread-compatible. class OrderedMultiQueue { public: using Callback = std::function)>; - // Will wait to see at least one value for each unfinished queue before - // dispatching the next smallest value across all queues. OrderedMultiQueue() {} - ~OrderedMultiQueue() {} + + ~OrderedMultiQueue() { + for (auto& entry : queues_) { + CHECK(entry.second.finished); + } + } void AddQueue(const QueueKey& queue_key, Callback callback) { CHECK(FindOrNull(queue_key) == nullptr);