Angus Leeming wrote:

> It doesn't depend on BufferView. Why not make it a singleton class?

Sure... what's a singleton class?

> bucket1_ is filled with Cache::ItemPtrs to be dealt with by
> LoaderQueue::touch.
> 
> The timer calls LoaderQueue::loadNext every 100 ms.
> 
> LoaderQueue::loadNext calls
> emptyBucket(), which:
>         swap(bucket1_, bucket2_);
> Why is bucket2_ a class member. It is used only in
> LoaderQueue::emptyBucket() and is guaranteed to be empty on entry and on
> exit to the method. In fact why not:
> +void LoaderQueue::emptyBucket()
> +{
> +       cout << "emptying bucket" << endl;
> +       while (! bucket1_.empty()) {
> +               addToQueue(bucket1_.front());
> +               bucket1_.pop();
> +       }
> +}

This is to avoid having to lock the data. In this way we have always a
bucket ready for input that we are not touching. Is it reasonable?
It remembers me when it's raining inside my house because a hole in the
roof. Instead of emptying the bucket in a hurry risking to get the floor
wet, I have an aditional empty bucket ready and I swap them, and then go
calmly to empty the unused one.

> LoaderQueue::addToQueue takes this Cache::ItemPtr and adds it to the queue
> of items to be processed, cache_queue_, if not already there.
> 
> Why not:
>         void LoaderQueue::addToQueue(Cache::ItemPtr & item)
> (Ie, pass by reference). It isn't a simple pointer and so will add
> overhead passing by value as you do now.

You are perfectly right, I though it was.

> Once cache_queue_ is initialised, loadNext instigates the actual loading
> of the Cache::ItemPtrs.
> 
> I'm a bit confused by cache_set_ and cache_queue_. Could you help me?
> 

We need a queue with 'reprioritization'. That's it: if a new entry is added,
then it is added to the top. If the entry was already there, then we have
to move it to the top (or equivalently, remove it and add it to the top). 
This queue is implemented as a list and is called cache_queue_.
In order to make faster the insertion in the 'don't have it' case (the most
common?), I've added a set with the same entries to check if the new entry
is not already on the queue. If it's not, then qe have only to add it tot
the top (no checking). Maybe this set part does not worst it?

This is the simplest implementation I've could think. Does it sounds
reasonable?

Thanks, Alfredo


Reply via email to