Commit f6525468 authored by Max Kellermann's avatar Max Kellermann

db/update/Queue: use std::list instead of std::queue

The problem with std::queue is that it doesn't give us enough control. The method Clear() is a kludge already, but soon, we'll need filtering.
parent d64edb68
...@@ -26,7 +26,7 @@ UpdateQueue::Push(const char *path, bool discard, unsigned id) ...@@ -26,7 +26,7 @@ UpdateQueue::Push(const char *path, bool discard, unsigned id)
if (update_queue.size() >= MAX_UPDATE_QUEUE_SIZE) if (update_queue.size() >= MAX_UPDATE_QUEUE_SIZE)
return false; return false;
update_queue.emplace(path, discard, id); update_queue.emplace_back(path, discard, id);
return true; return true;
} }
...@@ -37,6 +37,6 @@ UpdateQueue::Pop() ...@@ -37,6 +37,6 @@ UpdateQueue::Pop()
return UpdateQueueItem(); return UpdateQueueItem();
auto i = std::move(update_queue.front()); auto i = std::move(update_queue.front());
update_queue.pop(); update_queue.pop_front();
return i; return i;
} }
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "check.h" #include "check.h"
#include <string> #include <string>
#include <queue>
#include <list> #include <list>
struct UpdateQueueItem { struct UpdateQueueItem {
...@@ -44,7 +43,7 @@ struct UpdateQueueItem { ...@@ -44,7 +43,7 @@ struct UpdateQueueItem {
class UpdateQueue { class UpdateQueue {
static constexpr unsigned MAX_UPDATE_QUEUE_SIZE = 32; static constexpr unsigned MAX_UPDATE_QUEUE_SIZE = 32;
std::queue<UpdateQueueItem, std::list<UpdateQueueItem>> update_queue; std::list<UpdateQueueItem> update_queue;
public: public:
bool Push(const char *path, bool discard, unsigned id); bool Push(const char *path, bool discard, unsigned id);
...@@ -52,7 +51,7 @@ public: ...@@ -52,7 +51,7 @@ public:
UpdateQueueItem Pop(); UpdateQueueItem Pop();
void Clear() { void Clear() {
update_queue = decltype(update_queue)(); update_queue.clear();
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment