X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FLoaderQueue.C;h=c21726d5562ff1a80958c06e8abf5ea40442ace8;hb=33243f70037b067f90d1574b74b34f90a2ef2aa1;hp=f7332d06eb48ec5f495925ce6f54ffa977c85ebb;hpb=51ad0ec92fda951b3720b555bfdf19a1012a19dd;p=lyx.git diff --git a/src/graphics/LoaderQueue.C b/src/graphics/LoaderQueue.C index f7332d06eb..c21726d556 100644 --- a/src/graphics/LoaderQueue.C +++ b/src/graphics/LoaderQueue.C @@ -5,10 +5,13 @@ * * \author Alfredo Braunstein * - * Full author contact details are available in file CREDITS + * Full author contact details are available in file CREDITS. */ +#include + #include "LoaderQueue.h" +#include "GraphicsCacheItem.h" #include "debug.h" @@ -17,12 +20,13 @@ using std::endl; using std::list; - -namespace grfx { +namespace lyx { +namespace graphics { int LoaderQueue::s_numimages_ = 5; int LoaderQueue::s_millisecs_ = 500; + LoaderQueue & LoaderQueue::get() { static LoaderQueue singleton; @@ -32,18 +36,18 @@ LoaderQueue & LoaderQueue::get() void LoaderQueue::loadNext() { - emptyBucket(); lyxerr[Debug::GRAPHICS] << "LoaderQueue: " << cache_queue_.size() << " items in the queue" << endl; int counter = s_numimages_; while (cache_queue_.size() && counter--) { - if(cache_queue_.front()->status() == WaitingToLoad) - cache_queue_.front()->startLoading(); - cache_set_.erase(cache_queue_.front()); + Cache::ItemPtr ptr = cache_queue_.front(); + cache_set_.erase(ptr); cache_queue_.pop_front(); + if (ptr->status() == WaitingToLoad) + ptr->startLoading(); } - if (cache_queue_.size() || bucket_.size()) { + if (cache_queue_.size()) { startLoader(); } else { stopLoader(); @@ -69,17 +73,6 @@ LoaderQueue::LoaderQueue() : timer(s_millisecs_, Timeout::ONETIME), } -void LoaderQueue::emptyBucket() -{ - lyxerr[Debug::GRAPHICS] << "LoaderQueue: emptying bucket" - << endl; - while (! bucket_.empty()) { - addToQueue(bucket_.front()); - bucket_.pop(); - } -} - - void LoaderQueue::startLoader() { lyxerr[Debug::GRAPHICS] << "LoaderQueue: waking up" << endl; @@ -104,14 +97,6 @@ bool LoaderQueue::running() const void LoaderQueue::touch(Cache::ItemPtr const & item) -{ - if (! running_) - startLoader(); - bucket_.push(item); -} - - -void LoaderQueue::addToQueue(Cache::ItemPtr const & item) { if (! cache_set_.insert(item).second) { list::iterator @@ -124,7 +109,10 @@ void LoaderQueue::addToQueue(Cache::ItemPtr const & item) cache_queue_.erase(it); } cache_queue_.push_front(item); + if (!running_) + startLoader(); } -} // namespace grfx +} // namespace graphics +} // namespace lyx