Date: 2005-02-21 05:12:48
I used boost::signals in number of projects and found one thing
inconvenient. I could easily connect anything to signal but sometimes it
became hard to disconnect form it.
It's ok if a connection time is bounded by a lifetime of trackable
or connection objects. I used to use Group id for disconnection,
but sometimes I needed it for call priority. ( In that case I would write
a special GroupCompare function but it looked ugly. )
For experimental purposes, I constructed an alternative approach.
For connection/disconnection management I used the following syntax:
void test( bool, int );
void f( bool );
signal<void (bool)> s;
s.connect( &Test::test, t, _1, 5 );
s.disconnect( &Test::test, t, _1, 5 );
s.connect( &f, _1 );
s.disconnect( &f, _1 );
I just form a hash code from the arguments.
It certainly makes the process longer, but in most cases I don't need
something extremely fast there. In my projects,
the performance is important in invocation process.
It's only a variant, there might be a lot of other ways.
So actually my suggestion is why not to have both approaches of
connection/disconnection management? One for fast
connection/disconnection and the other for
extra control over it.
-- Best regards, Nick mailto:kolach56_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk