Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2000-11-24 16:37:39


>In message <200011232346.PAA22491_at_[hidden]>, Jesse Jones
><jesjones_at_[hidden]> writes
>>My callback usage almost always looks something like this:
>>
>> mPushButton = new PushButton(...);
>>
>> boost::callback<void> callback(this, &MyObject::OnClicked);
>> mPushButton->SetNotifier(callback);
>>
>>This pretty much mandates at least one copy. It's true that I don't
>>*need* to have callbacks be copyable, but if they're not I think I'll
>>always be wrapping them up with shared_ptr which seems silly.
>
>I don't see the need for any reference counting in this at all, which I
>think demonstrates the point I was getting at. The context you've used
>above is that of a GUI framework, where the effect of reference counting
>such objects is, at best, going to be a drop in the ocean :-}

Evidently I wasn't making myself clear enough. What you were suggesting
was that callback would be non-copyable and clients would have to use
shared_ptr<callback> if they wanted a copyable version. All that I'm
saying is that callbacks are copied sufficently often that I'd prefer to
make callback itself copyable.

>More generally, there is a general trend away from hidden body reference
>counting as an optimisation as it has proved to be awkward and not
>always an optimisation. For instance, the standard basic_string makes
>effective reference counting awkward, and often a waste of effort. And
>then there's multithreading. IIRC, the next (or even current) version of
>Dinkumware has dropped reference counting, and SGI doesn't use it at
>all. I don't see a technical reason to buck this trend and plenty of
>technical reasons to follow it.

Well, callbacks are a more manageable case since we don't have to deal
with copy on write.

  -- Jesse


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