CHECKs that all queues are finished on destruction. (#106)

master
Damon Kohler 2016-10-27 11:45:27 +02:00 committed by GitHub
parent 15f9244577
commit 224b068fe9
1 changed files with 8 additions and 4 deletions

View File

@ -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<void(std::unique_ptr<Data>)>;
// 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);