|
Boost : |
From: Jody Hagins (jody-boost-011304_at_[hidden])
Date: 2005-02-11 12:26:29
On Fri, 11 Feb 2005 16:51:48 +0200
"Peter Dimov" <pdimov_at_[hidden]> wrote:
> Last time I looked, alternatives beat Boost.Signals because they don't
>
> handle the corner cases of slot disconnection during signal
> invocation.
>
> Example:
>
> R operator()(void) const
> {
> typename list::iterator i = list_.begin();
> while (i != list_.end())
> {
> if (i->function_)
> {
> (i++)->function_();
> }
> else
> {
> i = list_.erase(i);
> }
> }
> }
>
> (from Jody Hagins's implementation)
>
> AFAICS this doesn't work if (i++)->function_() disconnects *(i+1).
>
> To handle disconnection correctly, one needs to invoke a temporary
> list<>. I haven't looked at what boost::signal does, but this may
> account for the dynamic allocations that have been reported.
That implementation was a very first try at something for comparison
purposes. Because of the performance differences, I modified that code
a bit and added a few pieces of functionality, one of which is the
ability to replace a slot and/or disconnect a slot while it is being
handled.
The performance difference was measurable, but very small. A copy of
the list is not necessary to implement this feature.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk