Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-11-22 15:16:28


--- In boost_at_[hidden], "Peter Dimov" <pdimov_at_m...> wrote:
> From: "William Kempf" <sirwillard_at_m...>
>
> > As for ref-counting vs. cloning... that's a trickier question.
>
> Indeed. :-)
>
> > I'm
> > leaning in favor of ref-counting since a callback is likely to be
> > passed around frequently.
>
> That's not obvious to me. Why is a callback likely to be passed
around
> frequently - in performance critical code?

Well, I'm willing to concede that the term "frequently" is a
misnomer. I suppose that most general usages of a callback won't
copy more than a few times at the most. However, I was considering
how callbacks could be stored within a container which can cause
frequent copies to be made. There's ways around this, though, so
maybe I need to rethink my position here.

> > However, I'd love to hear a list of pros
> > and cons from people for both strategies just to make sure I've
not
> > missed any that could change my opinion (and to help others
formulate
> > their own opinions as well).
>
> A list of pros and cons won't help, because a cloning callback and a
> reference counted callback are different concepts. Sometimes you'll
need the
> one, sometimes the other.

This I'm not so sure about. Yes, their behavior is radically
different. However, I find it difficult to think of specific
situations where one would be the answer while the other would not.
Can you spark my thinking on this?
 
> One other point that crossed my mind is that building a refcounted
callback
> on top of a cloning one is (relatively) easy, while the opposite is
not
> trivial. Assuming the compiler has void returns, of course.

If both are truly useful then I'd agree that the cloning version is
the more important of the two.

Bill Kempf


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