From f276b73d974a4b47d50e71922846efe9ee0b1409 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 24 Nov 2009 14:26:00 -0800 Subject: DEV-41998 - refactor mediadataclient to use a std::list, and re-sort every time an item is pulled off the queue Review #43 This change refactors mediadataclient to no longer use a PriorityQueue (which sorts only on insertion), but rather just use a std::list which is re-sorted on insert, and also when "popped" (at the time the queue timer goes off). Also implemented a unit test to make sure re-sorting occurs on timer tick. --- indra/newview/llmediadataclient.h | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'indra/newview/llmediadataclient.h') diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index d5dd050111..812e9cbdec 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -195,30 +195,14 @@ protected: private: - // Comparator for PriorityQueue - class Comparator - { - public: - bool operator() (const request_ptr_t &o1, const request_ptr_t &o2) const; - private: - static F64 getObjectScore(const LLMediaDataClientObject::ptr_t &obj); - }; + typedef std::list request_queue_t; - // PriorityQueue - class PriorityQueue : public std::priority_queue< - request_ptr_t, - std::vector, - Comparator > - { - public: - // Return whether the given object is in the queue - bool find(const LLMediaDataClientObject::ptr_t &obj) const; - - friend std::ostream& operator<<(std::ostream &s, const PriorityQueue &q); - }; + // Comparator for sorting + static bool compareRequests(const request_ptr_t &o1, const request_ptr_t &o2); + static F64 getObjectScore(const LLMediaDataClientObject::ptr_t &obj); friend std::ostream& operator<<(std::ostream &s, const Request &q); - friend std::ostream& operator<<(std::ostream &s, const PriorityQueue &q); + friend std::ostream& operator<<(std::ostream &s, const request_queue_t &q); class QueueTimer : public LLEventTimer { @@ -232,6 +216,9 @@ private: LLPointer mMDC; }; + // Return whether the given object is in the queue + bool find(const LLMediaDataClientObject::ptr_t &obj) const; + void startQueueTimer(); void stopQueueTimer(); void setIsRunning(bool val) { mQueueTimerIsRunning = val; } @@ -242,7 +229,7 @@ private: bool mQueueTimerIsRunning; - PriorityQueue *pRequestQueue; + request_queue_t *pRequestQueue; }; -- cgit v1.2.3