Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2002-03-09 22:26:32


----- Original Message -----
From: "David Abrahams" <david.abrahams_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, March 09, 2002 2:49 PM
Subject: Re: [boost] Interest in a cache class?

> I'm interested if it interacts intelligently with shared_ptr.
> What I want is a cache which can be incrementally flushed, such that
the
> only items that will be destroyed have a reference count of zero.

My design uses 'cache<...>::handle' instead of 'boost::shared_ptr' and
the existance of a 'cache<...>::handle' does not guarantee that the
objects is being kept around.

My rationale is as follows: the existance of a handle to an object is
not the best indicator of whether or not the object should be
discarded. Searching the cache for an object is a realitively slow
O(lg n) operation. Therefore I want to perform this action only once
at startup where possible. However, having lots of shared_ptrs
keeping the cached objects alive defeats the purpose of the cache.
Separating the handles from the mechanism for discarding old objects
from the cache means the user never has to worry about that.

Even without that, I would prefer a pointer with an instrusive
reference count. The difference in efficiency (in both memory usage
and execution time) seems very significant to me.

--
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