+2003-02-25 Alfredo Braunstein <abraunst@libero.it>
+
+ * LoaderQueue.[Ch]: a simplification of the code, eliminated
+ the unneeded input bucket.
+
2003-02-25 Alfredo Braunstein <abraunst@libero.it>
* PreviewLoader.C (FindFirst): use ==, not < with std::find.
int LoaderQueue::s_numimages_ = 5;
int LoaderQueue::s_millisecs_ = 500;
+
LoaderQueue & LoaderQueue::get()
{
static LoaderQueue singleton;
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();
}
-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;
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<Cache::ItemPtr>::iterator
cache_queue_.erase(it);
}
cache_queue_.push_front(item);
+ if (!running_)
+ startLoader();
}
///
static int s_millisecs_ ;
- /// Moves bucket_ to cache_queue_
- void emptyBucket();
- /// Adds or reprioritizes one element in cache_queue_
- void addToQueue(Cache::ItemPtr const & item);
/** This is the 'threaded' method, that does the loading in the
* background.
*/
+2003-02-25 Alfredo Braunstein <abraunst@libero.it>
+
+ * forkedcontr.C (timer): Start the loop afresh if an item is deleted.
+ Emiting the signal can result in an arbitrary change to the list.
+
2003-02-25 Angus Leeming <leeming@lyx.org>
* forkedcontr.C (timer): Use a while loop rather than for; makes it
}
if (remove_it) {
- // Emit signal and remove the item from the list
+ forkedCalls.erase(it);
+
actCall->emitSignal();
delete actCall;
- // erase returns the next element in the list
- it = forkedCalls.erase(it);
+
+ /* start all over: emiting the signal can result
+ * in changing the list (Ab)
+ */
+ it = forkedCalls.begin();
} else {
++it;
}