From: Larry Evans (cppljevans_at_[hidden])
Date: 2003-11-15 20:05:27
On 11/15/2003 05:44 PM, Larry Evans wrote:
> On 11/15/2003 01:48 PM, Philippe A. Bouchard wrote:
>> Larry Evans wrote:
>>> requires synchronization for decrement of reference count.
>>> The cost is extra memory in the pointers.
>> Is this a "probabilistic" solution or will it always work?
> AFAICT, it'll always work. This is because instead of accessing
> the pointee, only the smart pointer is accessed. I'm assuming that
> the smart pointers are in the same thread; hence, there's no need
> to synchronize. Only when a smart pointer is destroyed does
> the pointee need to be accessed.
I've gotta amend that. It'll work as long as the weights in the
smart pointers don't drop to 1. If this happens, then the weight
associated with the pointee needs to be augmented to maintain
RC(N) = sum(N) weight<X,N>
(see section 2 of the previously cited reference). where:
RC(N) = the reference count for pointee N.
sum weight<X,N> = sum of weights of all smart pointers, X with pointee, N.
When a smart pointer is removed or changes it's pointee, the smart
pointer's weight is decremented from the pointee's RC.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk