GNOME Bugzilla – Bug 93694
Glib::Dispatcher and arbitrary MainContext
Last modified: 2004-12-22 21:47:04 UTC
The signal in the DispatcherNotifier connect only to the default MainContext. The proposed enhancement offers the possibility to use an arbitrary MainContext.The patch adds an additional constructor to Glib::Dispatcher, that accepts a reference to Glib::RefPtr<MainContext> an connects the DispatcherNotifier signal to that context.
Created attachment 11174 [details] [review] the patch adds the possibility to use an arbitrary MainContext
I think the constructor should be marked "explicit". I think Daniel Elstner needs to approve this patch.
You are right. Making it "explicit" would be better. Sorry, that I did not do it. As a test for the patch I modified Daniel Elstner's dispatcher example. The modified version contains 2 mainloops which a dispatcher signal in each direction. It worked with no obvious problems. I may of course have overlooked something. Is there any interest for an additional dispatcher example if this patch is accepted?
Yes, an example would probably be helpful.
I will clean up and comment the example tomorrow and attach it to this bug as another patch against the cvs tree.
Created attachment 11199 [details] [review] New complete patch. includes modifications in examples/threads/Makefile.am for now dispatcher example (next attachment)
Created attachment 11200 [details] new file: examples/thread/dispatcher2.cc (additional dispatcher example)
Could not build todays CVS tree because some directory was missing (tests/dialog or something similar) and autogen.sh complained.The files that were also included in the first patch (dispatcher.cc and dispatcher.h from glib/glibmm) built last time I tried (before I submitted the first patch) and the new example builds fine with a patched version of gtkmm-1.3.23, which is the same as the cvs version in the critical areas. The only minor change to dispatcher.h is the addition of "explicit". The only thing I could not try to build was the modified Makefile.am in the examples/thread directory, but I am pretty sure its fine.
Line 89 of the example should better be something like // Create a joinable thread -- it needs to be joined, otherwise its a memory leak sorry
I just applied your first patch with some modifications (mostly reducing code duplication). Thanks. I'm going to look at your example now. Erm, try cvs update -Pd to get new directories.
OK, the example is in CVS now. Thanks for your work. There were some memory visibility problems in the code which I (hopefully) fixed, apart from a few stylistic issues. Could you please have a look at my changes in case I did something that wasn't intended? --Daniel
Hej Daniel! Everything you did is perfect! And don't thank me - I am the one who should be (and who is) grateful.You are all doing a great job! Thanks for incorporating the patch and the example. I did learn a few things from the way you fixed it. Thanks a lot! Danke schön! Stephan
Heh, kein Problem ;)