Re: Multi-threaded GTK+



Tor Lillqvist <tml iki fi> writes:

> Soeren Sandmann writes:
>  > No, you are right, but what if all gdk_window_new() calls were done by
>  > the main thread?
> 
> That is not enough, as the test program attached to the bug report
> showed. Doing certain operations on windows created in another thread
> causes deadlock in the current GTK+ on Win32.

I think you can fix this if you simply move the code that retrieves
messages from the win32 queue outside the GDK_THREADS_ENTER()
/ GDK_THREADS_LEAVE() pair in gdk_event_dispatch().

That begs the question, however, of how you get the main thread
to call gdk_window_new() if it is busy doing something else.

A straightforward (I won't say simple) architecture that would
seem to work to me would be:

 If GDK is initialized in threaded mode, then an extra thread
 is created that:

  - Acts as a server for window creation
  - Receives all events and files them into the GDK queue

This would create a threading model that should be compatible
with the model under X11 ... a single event queue and you
have to acquire the GDK lock to do GTK+ or GDK operations.

Regards,
                                        Owen



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