
Frank Mori Hess wrote:
I hit the same problem, I had to manually disconnect at the beginning of my destructors, see
Thanks, I must have missed that post of yours and feel a little stupid about raising the same question again now ;).
Thread-safe automatic disconnect from non-static member functions seems like it would require some kind of extension to the language itself, like a pre-destructor.
There is also the possibility of using a wrapper template instead of a base class to put the tracking functionality to the top of the class hierarchy, but I don't think I particularly like that approach, especially as measures to "finalize" the hierarchy would have to be taken.
I recently did the same thing as you, my signals implementation is attached, if you are interested. The namespaces are different in my code, ::boost is ::EPG and ::boost::signals is ::EPG::signalslib.
Thanks for the code, it looks very promising. I was hoping it could be done with a little less runtime overhead (per slot mutex + polymorphism + shared_ptr), but I have to investigate the available options some more. I have one small suggestion for now: You could perhaps move the connection mutex to the base class to avoid too much per-Signature code repetition (use a private virtual do_disconnect() for forwarding, for example). Regards Timmo Stange