]> git.lyx.org Git - features.git/commitdiff
Alfredo's setPriority patch to the graphics LoaderQueue.
authorAngus Leeming <leeming@lyx.org>
Tue, 25 Feb 2003 11:20:59 +0000 (11:20 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 25 Feb 2003 11:20:59 +0000 (11:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6235 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/lyx_gui.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/lyx_gui.C
src/graphics/ChangeLog
src/graphics/LoaderQueue.C
src/graphics/LoaderQueue.h
src/graphics/PreviewLoader.C

index 3a7e57061dfabb7626aac1a11b78b0a7d89bf1d1..cbb38178079037fac5101537ed0bff85b0fceb41 100644 (file)
@@ -1,3 +1,7 @@
+2003-02-22  Alfredo Braunstein <abraunst@libero.it>
+
+       * lyx_gui.C (parse_init): added a call to LoaderQueue::setPriority
+
 2003-02-21  Angus Leeming  <leeming@lyx.org>
 
        * Timeout_pimpl.[Ch]: removed.
index e78aa48fec708ea05585a5637d26627100754b90..eecc425a57198f11171954c62a5eeac529cf0473 100644 (file)
@@ -24,6 +24,7 @@
 #include "lyxrc.h"
 #include "lyxfont.h"
 #include "funcrequest.h"
+#include "graphics/LoaderQueue.h"
 
 // FIXME: move this stuff out again
 #include "bufferlist.h"
@@ -118,6 +119,8 @@ void lyx_gui::parse_init(int & argc, char * argv[])
        lyxrc.dpi = getDPI();
 
        initEncodings();
+
+       LoaderQueue::setPriority(10,100);
 }
 
 
index 3c4c399c4e5c06dad7a7ed091a7b28af3a6ff9c2..d3e96357fc9592d461257f1d32384b8017a30462 100644 (file)
@@ -1,3 +1,7 @@
+2003-02-22  Alfredo Braunstein <abraunst@libero.it>
+
+       * lyx_gui.C (parse_init): added a call to LoaderQueue::setPriority
+
 2003-02-17  Rob Lahaye  <lahaye@snu.ac.kr>
 
        * FormBibTeX.C: add double click to choose from list.
index 491534866f18e5369fe14ef8aafc7bbd73a998d1..0be4e51398ffcddd1b1a2c8e5dac20c2d513db97 100644 (file)
@@ -23,6 +23,7 @@
 #include "lyx_main.h"
 #include "lyxrc.h"
 #include "lyxfont.h"
+#include "graphics/LoaderQueue.h"
 
 // FIXME: move this stuff out again
 #include "bufferlist.h"
@@ -171,6 +172,8 @@ void lyx_gui::parse_init(int & argc, char * argv[])
 
        // must do this /before/ lyxrc gets read
        lyxrc.dpi = getDPI();
+
+       LoaderQueue::setPriority(10,100);
 }
 
 
index 788e5cf45311546913323d33415ef4e6a31f8002..ff1909a8efbdab0e5d39b97751d459668e2e29a6 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-21  Alfredo Braunstein  <abraunst@libero.it>
+       
+       * LoaderQueue.[Ch] (setPriority): added
+       
+       * PreviewLoader.C (finishedGenerating): reversed the loading order so 
+       first images get 'touched' last, and so load first.
+
 2003-02-20  Alfredo Braunstein  <abraunst@libero.it>
 
        * LoaderQueue.[Ch]: added. Implements a service queue that loads
index 73062317b6ec31501f87ef04457b3f731f5c22c0..85f8311b51b25ad4413897d6ec90ddceba29f3a1 100644 (file)
@@ -20,6 +20,8 @@ using std::list;
 
 namespace grfx {
 
+int LoaderQueue::s_numimages_ = 5;
+int LoaderQueue::s_millisecs_ = 500;
 
 LoaderQueue & LoaderQueue::get()
 {
@@ -34,7 +36,7 @@ void LoaderQueue::loadNext()
        lyxerr[Debug::GRAPHICS] << "LoaderQueue: "
                                << cache_queue_.size()
                                << " items in the queue" << endl; 
-       int counter = 10;
+       int counter = s_numimages_;
        while (cache_queue_.size() && counter--) {
                if(cache_queue_.front()->status() == WaitingToLoad)
                        cache_queue_.front()->startLoading();
@@ -49,7 +51,18 @@ void LoaderQueue::loadNext()
 }
 
 
-LoaderQueue::LoaderQueue() : timer(100, Timeout::ONETIME), 
+void LoaderQueue::setPriority(int numimages , int millisecs)
+{
+       s_numimages_ = numimages;
+       s_millisecs_ = millisecs;
+       lyxerr[Debug::GRAPHICS] << "LoaderQueue:  priority set to "
+                               << s_numimages_ << " images at a time, "
+                               << s_millisecs_ << " milliseconds between calls" 
+                               << endl;
+}
+       
+
+LoaderQueue::LoaderQueue() : timer(s_millisecs_, Timeout::ONETIME), 
                             running_(false)
 {
        timer.timeout.connect(boost::bind(&LoaderQueue::loadNext, this));
@@ -71,6 +84,7 @@ void LoaderQueue::startLoader()
 {
        lyxerr[Debug::GRAPHICS] << "LoaderQueue: waking up" << endl;
        running_ = true ;
+       timer.setTimeout(s_millisecs_);
        timer.start();
 }
 
index aec1c9d7d8a4966dc9e35a261ddeb98c638009b5..52db71313e2b9b95e14f582ece38bc4f1b85e547 100644 (file)
@@ -33,34 +33,48 @@ namespace grfx {
 
 class LoaderQueue {
 public:
-       //use this to request a loading
+       /// Use this to request that the item is loaded.
        void touch(Cache::ItemPtr const & item);
-       //query if the clock is ticking
+       /// Query whether the clock is ticking.
        bool running() const;
-       //get the and only instance of the class
+       ///get the and only instance of the class
        static LoaderQueue & get();
+       /** Adjusts the queue priority:
+        *  numimages is the number of images loaded in a particular call
+        *  from the timer.
+        *  millisecs is the time interval between calls.
+        *  Higher numimages, lower millisecs means higher priority.
+        */
+       static void setPriority(int numimages , int millisecs);
 private:
-       //this class is a singleton class... use LoaderQueue::get() instead
+       /// This class is a singleton class... use LoaderQueue::get() instead
        LoaderQueue();
-       //in-progress loading queue (elements are unique here) 
+       /// The in-progress loading queue (elements are unique here).
        std::list<Cache::ItemPtr> cache_queue_;
-       //makes faster the insertion of new elements
+       /// Used to make the insertion of new elements faster.
        std::set<Cache::ItemPtr> cache_set_;
-       //newly touched element go here, loadNext move them to cache_queue_
+       /// Newly touched elements go here. loadNext moves them to cache_queue_
        std::queue<Cache::ItemPtr> bucket_;
-       //
+       ///
        Timeout timer;
-       //
+       ///
        bool running_;
-       //moves bucket_ to cache_queue_
+       ///
+       static int s_numimages_ ;
+       ///
+       static int s_millisecs_ ;
+
+       /// Moves bucket_ to cache_queue_
        void emptyBucket();
-       //adds or reprioritizes one element in cache_queue_
+       /// Adds or reprioritizes one element in cache_queue_
        void addToQueue(Cache::ItemPtr const & item);
-       //this is the 'threaded' method, that does the loading in background
+       /** This is the 'threaded' method, that does the loading in the
+        *  background.
+        */
        void loadNext();
-       //
+       ///
        void startLoader();
-       //
+       ///
        void stopLoader();
 };
 
index d2aef43d579d2cd82657bff2fc98f46b28b1a9b0..c5c4d4e9abeaa6bf06e548aec7dc5fde8e5efa03 100644 (file)
@@ -543,8 +543,10 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
        in_progress_.erase(git);
 
        // Tell the outside world
-       std::list<PreviewImagePtr>::const_iterator nit  = newimages.begin();
-       std::list<PreviewImagePtr>::const_iterator nend = newimages.end();
+       std::list<PreviewImagePtr>::const_reverse_iterator 
+               nit  = newimages.rbegin();
+       std::list<PreviewImagePtr>::const_reverse_iterator 
+               nend = newimages.rend();
        for (; nit != nend; ++nit) {
                imageReady(*nit->get());
        }