Boost logo

Boost :

From: Nathan Myers (ncm_at_[hidden])
Date: 1998-12-06 18:04:14


Beman Dawes writes:
> Greg has two implementations (with identical interfaces) of
> shared_ptr:
>
> (1) An "direct" version which privately holds the T* and a pointer
> to a reference counter on the heap.
>
> (2) An "indirect" version which privately holds a single pointer
> to a heap allocated struc which contains the T* and reference
> counter.
>
> What should we do:
>
> * Pick one implementation? If so, which one? (Greg's preference.)
> * Supply both with different names? What are good names, then?

There is a third option: parameterize. However, I wouldn't
advocate that. Ultimately we should let Greg choose, but
if I were to advise him I would choose the "direct" version.
Simple benchmarks are unlikely to distinguish the two, but
on a heavily-loaded system the indirect version is more
vulnerable to locality effects and to memory manager
fragmentation.

An intrusive version for use where you can put the reference-counter
in the referent would be useful too, but should have a different name.

Incidentally, these will be interesting to make thread-safe, and
more interesting to make efficiently thread-safe. Such thread-safety
is inherently non-portable, but where better to encapsulate it than
in the boost library?

Some work on encapsulation of concurrency primitives for a variety
of architectures is found in GNU glibc-2.1.

Nathan Myers
ncm_at_[hidden]
------------------------------------------------------------------------
Free Web-based e-mail groups -- http://www.eGroups.com


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