Re: Glib::SignalIO Help



On Thu, 11 Nov 2010 22:49:05 -0600
Michael Sierks <msierks sierkstech net> wrote:
> Hello,
> 
> I am writing a network application and currently have a separate
> thread for handling connections. But I am having an issue with
> calling "Glib::signal_io().connect()" to monitor a file descriptor in
> the thread. Whenever I do the gui freezes for some reason. This is a
> little puzzling, would anyone know why ?

You had better explain a bit more what you are trying to do, possibly
with a test case. Glib::signal_io().connect() connects the source to the
main (GUI) program loop, not any arbitrary main loop any particular
worker thread may be running.

You can connect to a particular thread's main loop if you do it the long
way of course, using Glib::IOSource::attach().

Note that because sigc::trackable is not thread safe, and some of the
main loop code in glibmm is also not thread safe, all these calls
should be made in the thread in which the callback is to execute (which
also means that Glib::signal_io().connect() should only be called in
the main GUI thread).  If you want greater thread safety than that,
then you will need to use glib directly, or use a different wrapper
library.  Also don't forget to call g_thread_init()/Glib::thread_init().

Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]