From d2af82aafc9ef569c9552f269ccf4e4fd38a1f33 Mon Sep 17 00:00:00 2001 From: Monty Brandenberg Date: Fri, 6 Jul 2012 19:14:42 -0400 Subject: 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). --- indra/llcorehttp/_httpinternal.h | 8 ++++++++ indra/llcorehttp/_httpreadyqueue.h | 39 +++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h index 4ccace2b30..5f966500c9 100644 --- a/indra/llcorehttp/_httpinternal.h +++ b/indra/llcorehttp/_httpinternal.h @@ -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 { diff --git a/indra/llcorehttp/_httpreadyqueue.h b/indra/llcorehttp/_httpreadyqueue.h index 87828834dc..968ca01258 100644 --- a/indra/llcorehttp/_httpreadyqueue.h +++ b/indra/llcorehttp/_httpreadyqueue.h @@ -30,6 +30,7 @@ #include +#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 HttpReadyQueueBase; + +#else + typedef std::priority_queue, 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 -- cgit v1.2.3