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).
master
Monty Brandenberg 2012-07-06 19:14:42 -04:00
parent f37b90df50
commit d2af82aafc
2 changed files with 44 additions and 3 deletions

View File

@ -32,6 +32,14 @@
// 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
{

View File

@ -30,6 +30,7 @@
#include <queue>
#include "_httpinternal.h"
#include "_httpoprequest.h"
@ -47,10 +48,18 @@ namespace LLCore
/// Threading: not thread-safe. Expected to be used entirely by
/// 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 *,
std::deque<HttpOpRequest *>,
LLCore::HttpOpRequestCompare> HttpReadyQueueBase;
#endif // LLCORE_READY_QUEUE_IGNORES_PRIORITY
class HttpReadyQueue : public HttpReadyQueueBase
{
public:
@ -66,16 +75,40 @@ protected:
void operator=(const HttpReadyQueue &); // Not defined
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
{
return c;
return *this;
}
container_type & get_container()
{
return c;
return *this;
}
}; // end class HttpReadyQueue