[vlc-devel] [PATCH 06/13] qt: medialib: use list cache from MLBaseModel

Romain Vimont rom1v at videolabs.io
Tue Nov 24 10:41:33 CET 2020


On Tue, Nov 24, 2020 at 10:15:05AM +0100, Pierre Lamot wrote:
> Hi
> 
> > -    mutable std::vector<std::unique_ptr<T>> m_item_list;
> > -    mutable bool m_initialized;
> > -    mutable size_t m_total_count;
> > -    mutable size_t m_offset; /* offset of m_item_list in the global
> > list */
> > +    /* Data loader for the cache */
> > +    struct Loader : public ListCacheLoader<std::unique_ptr<T>>
> > +    {
> > +        Loader(const MLSlidingWindowModel &model)
> > +            : m_model(model)
> > +            , m_searchPattern(model.m_search_pattern)
> > +            , m_sort(model.m_sort)
> > +            , m_sort_desc(model.m_sort_desc)
> 
> Do you need to keep copy each criteria here? can't you use them directly
> from the m_model upon which you keep a reference. I would expect the cache
> to be invalidated when they changes in the Model.

Here the reference m_model is just temporary to delegate count/load
calls, but the goal is to remove it (which is done in patch 8) because
the loader can live longer than the model.

> That being said, this probably makes sense once your request is ran in a
> separate thread.

Exactly :)


More information about the vlc-devel mailing list