+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.
#include "lyxrc.h"
#include "lyxfont.h"
#include "funcrequest.h"
+#include "graphics/LoaderQueue.h"
// FIXME: move this stuff out again
#include "bufferlist.h"
lyxrc.dpi = getDPI();
initEncodings();
+
+ LoaderQueue::setPriority(10,100);
}
+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.
#include "lyx_main.h"
#include "lyxrc.h"
#include "lyxfont.h"
+#include "graphics/LoaderQueue.h"
// FIXME: move this stuff out again
#include "bufferlist.h"
// must do this /before/ lyxrc gets read
lyxrc.dpi = getDPI();
+
+ LoaderQueue::setPriority(10,100);
}
+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
namespace grfx {
+int LoaderQueue::s_numimages_ = 5;
+int LoaderQueue::s_millisecs_ = 500;
LoaderQueue & LoaderQueue::get()
{
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();
}
-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));
{
lyxerr[Debug::GRAPHICS] << "LoaderQueue: waking up" << endl;
running_ = true ;
+ timer.setTimeout(s_millisecs_);
timer.start();
}
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();
};
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());
}