Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-27 06:32:36


> On Thu, 26 Jul 2001 11:31:29 -0600, (Greg Colvin) said:
[...]
> >problem. I especially like that in Peter's solution the choice of
> >finalizer does not affect the type of the shared pointer. This
> >makes it easy for functions that create objects and return a
> >shared_ptr to hide their memory management implementation, and to
> >change it without forcing a recompilation of their callers. So I
> >am very much in favor of accepting Peter's shared_count.

On a related note,

http://groups.yahoo.com/group/boost/files/impl_ptr/impl_ptr.html

is another smart pointer with this property; it's semantics are
reconfigurable at runtime without changing the type. I intend to request a
formal review as soon as I finish the documentation for

http://groups.yahoo.com/group/boost/files/impl_ptr/variant.hpp

that uses impl_ptr as a building block.

> >A third set of complaints is the lack of thread safety, which I
> >suspect we should postpone until Boost::threads is ready.

One of the goals of shared_count is to 'centralize' the reference count
management. On win32 users can achieve a reasonable level of thread safety
by simply changing

--count

to

::InterlockedDecrement(&count)

in shared_count::impl_base::release. The only reason that I haven't already
done this in _WIN32/_MT builds is the <winbase.h> dependency that may not be
acceptable to some.

--
Peter Dimov
Multi Media Ltd.

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