Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2002-01-12 14:59:15


The proof is in the pudding, but I'll try to reply in short below.

> 1. Why the separate Storage and Ownership policies?

They are orthogonal for the most part. For example, there is no link between
the fact that you allocate a pointer with new and the fact that you
reference count it. Same pointer allocated with new you also may want to
reference link (maintain a linked list between all pointers to the same
object) or simply treat it as an auto_ptr. As far as the ownership policy is
concerned, the managed resource can be allocated anyhow and can actually not
be a pointer at all.

> 2. How are threading issues addressed? I see RefCountedMT but it doesn't
> have the proper "template <class> class OwnershipPolicy" signature so it
> cannot be used, am I missing something?

That's a bug, thanks for pointing it out. RefCountedMT is not intended to be
customized by the threading model, that's exactly why I used a different
class name from RefCounted. The history was - initially I wanted to
implement only one RefCounted class that supports whatever threading model.
Then I noticed that I can't customize it the way it needed, so I decided to
write a separate RefCountedMT class. That class is not supposed to support
different threading models - it just uses the static functions
AtomicIncrement and AtomicDecrement from ObjectLevelLockable.

I guess there's a more elegant approach to that, a la
allocator<T>::bind<U>::other. Or is it more elegant? :o)

> 3. Why are GetImpl*, Reset, Release free friends and not members?

See my other post.

Andrei


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