Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2002-03-11 12:33:08


----- Original Message -----
From: "David Abrahams" <david.abrahams_at_[hidden]>

> ----- Original Message -----
> From: "Rainer Deyke" <root_at_[hidden]>
>
> > > > However, having lots of shared_ptrs
> > > > keeping the cached objects alive defeats the purpose of the
cache.
> > >
> > > Maybe your purpose. When I've needed a cache, I've needed some
way
> > to
> > > prevent certain objects from being flushed.
> >
> > Why?
>
> Because the objects were "currently in use" - essentially because
they
> were likely to be needed again soon,

I remain unconvinced. There is no semantic difference between keeping
the same object around and discarding it and reloading on demand.
There is a difference in performance, but the cache itself is probably
in a better position to judge when objects should be discarded than
the user.

> but also because they were
> referenced by objects other than the cache.

This should not be a problem if the other references are all of type
'cache<...>::handle', since the object is always reloaded on reference
if it was discarded.

Actually, no that I think about it, there is a flaw in my design: if a
cached object accesses the cache in a member function, it can cause
itself to be unloaded. So you are right: there must be some way to
prevent objects from being unloaded when in use. I will implement
this soon.

--
Rainer Deyke | root_at_[hidden] | http://rainerdeyke.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk