|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-03-19 23:31:13
"Peter Dimov" <pdimov_at_[hidden]> writes:
>> The weak_ptr adds an extra count (1 word) but more importantly
>> requires a mutex, at least on platforms lacking more advanced
>> lock-free primitives such as InterlockedCompareExchange.
>
> The theoretical minimum cost of a non-intrusive pointer is:
>
> - per-instance pointer to the count;
> - one word for the count.
>
> Feature (1) above adds:
>
> - vtable
> - pointer
>
> The functor need not be present when not used, although the current code
> base does not do that. It can also be optimized out when it's an empty class
> with the help of boost::compressed_pair. Again, the current code base
> doesn't do it, but we're talking about the design-imposed overhead here.
You could also replace the vtable with a function pointer per
Boost.Function and eliminate some space overheads associated with
dynamic type info.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk