Skip to content
Snippets Groups Projects
Commit d2af82aa authored by Monty Brandenberg's avatar Monty Brandenberg
Browse files

Experiment with ignoring priority in the library. Let upper layers

sort things out or use policy classes (eventually) to arrange low
and high priority traffic.  Subjectively, I think this works better
in practice (as I haven't implemented a dynamic priority setter yet).
parent f37b90df
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,14 @@ ...@@ -32,6 +32,14 @@
// something wrong is probably happening. // something wrong is probably happening.
// If '1', internal ready queues will not order ready
// requests by priority, instead it's first-come-first-served.
// Reprioritization requests have the side-effect of then
// putting the modified request at the back of the ready queue.
#define LLCORE_READY_QUEUE_IGNORES_PRIORITY 1
namespace LLCore namespace LLCore
{ {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <queue> #include <queue>
#include "_httpinternal.h"
#include "_httpoprequest.h" #include "_httpoprequest.h"
...@@ -47,10 +48,18 @@ namespace LLCore ...@@ -47,10 +48,18 @@ namespace LLCore
/// Threading: not thread-safe. Expected to be used entirely by /// Threading: not thread-safe. Expected to be used entirely by
/// a single thread, typically a worker thread of some sort. /// a single thread, typically a worker thread of some sort.
#if LLCORE_READY_QUEUE_IGNORES_PRIORITY
typedef std::deque<HttpOpRequest *> HttpReadyQueueBase;
#else
typedef std::priority_queue<HttpOpRequest *, typedef std::priority_queue<HttpOpRequest *,
std::deque<HttpOpRequest *>, std::deque<HttpOpRequest *>,
LLCore::HttpOpRequestCompare> HttpReadyQueueBase; LLCore::HttpOpRequestCompare> HttpReadyQueueBase;
#endif // LLCORE_READY_QUEUE_IGNORES_PRIORITY
class HttpReadyQueue : public HttpReadyQueueBase class HttpReadyQueue : public HttpReadyQueueBase
{ {
public: public:
...@@ -66,16 +75,40 @@ class HttpReadyQueue : public HttpReadyQueueBase ...@@ -66,16 +75,40 @@ class HttpReadyQueue : public HttpReadyQueueBase
void operator=(const HttpReadyQueue &); // Not defined void operator=(const HttpReadyQueue &); // Not defined
public: public:
#if LLCORE_READY_QUEUE_IGNORES_PRIORITY
// Types and methods needed to make a std::deque look
// more like a std::priority_queue, at least for our
// purposes.
typedef HttpReadyQueueBase container_type;
const_reference & top() const
{
return front();
}
void pop()
{
pop_front();
}
void push(const value_type & v)
{
push_back(v);
}
#endif // LLCORE_READY_QUEUE_IGNORES_PRIORITY
const container_type & get_container() const const container_type & get_container() const
{ {
return c; return *this;
} }
container_type & get_container() container_type & get_container()
{ {
return c; return *this;
} }
}; // end class HttpReadyQueue }; // end class HttpReadyQueue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment