Re: GTK & Threads - Questioning safe practice.



Chris Caron (OTI) wrote:

i understand threads in gtk for the most part....
But what do you do when both functions call the same "share me function"
where that could simply be jsut a function that creates a gui image, or whatever.

since you have to impliment locking on the function, is it safe to unlock the main (since the function will again lock itself again)?

see below how share_me() is written and tell me if call_me() is valid?
If anyone could help out, that would be great!

    gdk_threads_enter/leave is a lock on a mutex which is shared with the
Gtk+ main loop (the main loop hold this mutex at certain times as well
as the user). Personaly I would use a GStaticMutex and then use
gdk_threads_enter/leave pairs only around accesses to gtk+ fuctions.

Cheers,
                                  -Tristan

See disscussion at:
http://developer.gnome.org/doc/API/2.0/glib/glib-Threads.html#GStaticMutex




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