On Thu, 17 Sep 2020 13:48:55 -0400 Jackson Campolattaro via gtkmm-list <gtkmm-list@gnome.org> wrote: > Hello, > > `Glib::Dispatcher` has syntax similar to a void signal, but there are cases > where it would be convenient to pass information between threads using the > same syntax. Obviously returning anything would be impossible, but is there > a technical reason not to have one way communication (e.g. > `Glib::Dispatcher<int>` that can be used a little like a > `sigc::signal<void(int)>`)? Obviously the user would have to be especially > careful about scope (don't pass references to things that might be deleted > before the other thread can act on the signal). In some cases it might also > make sense to pass a mutex alongside the value. > > Is this functionality not provided as part of libsigc++ just because it's > unsafe-by-default, or is there a deeper problem? According to this old > thread <https://mail.gnome.org/archives/gtkmm-list/2007-March/msg00063.html>, > libsigcX <https://sourceforge.net/projects/libsigcx/> provides something > similar, but it looks like it hasn't been updated in a very long time. > > If there's not an obvious issue that makes it impossible, I'll probably > write myself a wrapper class that gives me this kind of behavior.
Glib::Dispatcher uses a pipe to synchronize between threads. You could possibly serialize objects and send them over the pipe in a C++ standard non-conforming way (that would work with an int) but why bother? Just use an asynchronous queue as suggested, which is pretty much fool-proof and will work with non-trivial objects (using "trivial" in its C++-standard sense). _______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list