|
Boost : |
From: Greg Colvin (greg_at_[hidden])
Date: 2002-05-02 14:00:03
At 12:25 PM 05/02/2002, you wrote:
>"Greg Colvin" <greg_at_[hidden]> wrote in message
>news:5.1.0.14.0.20020502104307.02ad0560_at_GMMAIL...
>> >2. shared_ptr has significant size and speed overhead for COM and
>> >CORBA-style smart pointers
>>
>> In my experience, the fastest way to handle COM locally is to do AddRef
>> once when constructing a shared_ptr, and Release once when counter
>> goes to zero, and save the virtual function calls.
>
>Why do we need smart_ptr if every time I create I need to call AddRef and
>every time I destroy I need to check counter?
You automate the AddRef in a constructor or factory
function, and automate the release with a shared_ptr
deleter function. Then shared_ptr can do a fast local
count to manage copies. Something like:
void com_releaser(IUnknown* p) { p->Release(); }
template<class T> shared_ptr<T>
make_com_shared_ptr(IUnknown* p) {
p->AddRef();
return shared_ptr<T> (p,com_releaser);
}
>> >4. shared_ptr is a point in smart_ptr's design space.
>>
>> It could be, yes. And vice versa.
>
>No.
Actually, they are more like overlapping regions than points.
If you freeze either region, you could then expand the other
region to encompass it. But I agree that is would be easier
for the Loki design to swallow up the Boost shared_ptr design
than vice versa.
So, as, a swallowee, I want to be sure the swallower fully
digests all the swallowed nutrients.
>> Another bastion is years of experience with shared_ptr, which
>> indicates that it is "good enough" for most purposes, that it
>> can be tweaked over time to handle other important purposes,
>> and can provide hooks for user extension in unanticipated
>> ways. The syntax is easy for the most common case, easy
>> enough for anticipated extensions, and well within the skill
>> of those who would design new extensions.
>
>I assume that if we provide the same syntactic convenience and hooks for
>user extension we do as good as current version.
And the same binary compatibility. Then I will be happy and
shut up, leaving the rest of you to push the boundaries of
template metaprogramming.
>Well-slept last-night, Gennadiy.
Me too. Greg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk