Re: Gtk+: multi-threaded or not ?



On Tue, Feb 02, 2010 at 06:14:18PM +0530, Siddu wrote:
On Tue, Feb 2, 2010 at 5:56 PM, Pierre Wieser <pwieser trychlos org> wrote:

Reading this list, I see some questions which talk about "threads": main
thread, event thread, and so on.

I was not conscious Gtk+ was multithreaded. I'm conscious of asynchronous
code with the mail loop and idle function (which are rather in Glib, I
believe ?), but really not of multithread.

So is Gtk multithreaded, or not ?

Because if it is, I will have to deal with mutex, semaphores and all the
usual soup!!

Gtk+ is single threaded library

This is a bit too simplistic view.  Gtk+ is a thread-aware library.

This means if the application does not use threads neither does Gtk+ so
you don't need to care about mutexes and stuff at all.

However, Gtk+ knows about threads and goes to some length to be usable
in a multithreaded application by protecting its internal state by
locking (if threading is enabled).  Note that the only portable use of
threads with Gtk+ is to let only the thread running gtk_main() to
actually touch the GUI.

So Gtk+ is neither single-threaded nor multi-threaded in the usual sense
of these terms.

Yeti




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