Re: GTK and threads


"Vlietstra, Joe (NSSD)" <Joe Vlietstra ngc com> writes:

> Our group has previously written several multithreaded GTK applications.
> We had a problem with a new application, investigated, read the API docs,
> and now we are completely confused about GTK threads.
> The example applications in the API documentation contain the following
> code snippet:
>    gdk_threads_enter();
>    gtk_main();
>    gdk_threads_leave();
> gdk_threads_enter() is simply a wrapper function that locks the
> gdk_threads_mutex.  Similarly, gdk_threads_leave() is a wrapper that
> unlocks the mutex.  This means GTK main loop has a lock on the mutex
> and apparently holds this lock until the main loop exits.  If GTK main
> is always holding the mutex, how can other threads acquire the lock?

Have a look at gtkmain.c. The lock is (of course) released while the
main loop is being run.


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