Re: Multiple threads and gtk_main()



On Wed, 2007-07-11 at 22:06 +0100, Chris Vine wrote:
On Wed, 2007-07-11 at 08:59 +0200, Jonathan Winterflood wrote:
Hi,

Could the GAsyncQueue be configured to run a callback in the main
thread when a element (or whatever gets pushed into it) is ready, just
like one woud do with a GIOChannel ?

It would be cleaner than a timeout or an idle function I think. 

If you want to use it on a Unix system, then a pipe is the cleanest way
to do it.  If you don't mind a bit of C++, this is an example:

http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/notifier.h
http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/notifier.cpp

If you are using windows it is probably easiest to use a timeout.

Ah, I should have said that to make sense of this you also need to see:

http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/io_watch.h
http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/io_watch.cpp
which connects a file descriptor to the Glib main loop and
http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/pipes.h
http://efax-gtk.cvs.sourceforge.net/*checkout*/efax-gtk/efax-gtk/src/utils/pipes.cpp
which wraps a unix anonymous pipe.

Chris





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