GdkPixbuf cache in Nautilus revisited



First, a disclaimer. There's something wrong with the Nautilus icon cache
that makes it not cache was well as it should. This has nothing to do with
what I'm discussing here, and I'd like to ignore that for now.

As some no-doubt recall, Nautilus has an icon cache with a simple interface.
It returns GdkPixbuf objects for clients. The clients are not allowed to
modify the pixbufs, and they unref the pixbufs when they are done with them.

The cache wants to keep around any references to outstanding pixbufs. If a
client is still keeping the pixbuf around, the cache ought to remember it so
that other clients can share it.

The cache needs a way to know when the last reference to a pixbuf is
dropped, either at that moment, or after the fact at the next cache sweep.
The simpleminded approach is to can peek at the reference count at the time
of the cache sweep, and see if it's equal to 1 -- if not, there's something
other than the cache holding a reference, and the pixbuf should not be
released from the cache. That was the original implementation in Nautilus.

But then we made the reference count in GdkPixbuf be private, so I had to
ask for a new feature. At that time, there was a lot of discussion about how
to do this sort of thing. I remember we put a premium on coming up with a
design that would work with multiple levels of caches. Nautilus was changed
to use a "last unref" feature.

Before I go back to the dumb "look for reference count of 1 when we sweep
the cache" algorithm, I was wondering if there is some suitable feature in
GObject that I should be using for this.

?

    -- Darin




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]