On Mon, 2007-09-10 at 21:47 +0200, Luca D wrote: > Hello, > > I have one question regarding the use of clutter in a multi-threaded > application. Reading the documentation I do not understand if > clutter_threads_enter() and clutter_threads_leave() are needed: > a) to protect every call to clutter functions, or > b) only to protect accessing the same actor from different threads.
the latter: only to protect critical sections of the code, where you might call Clutter API (*any* Clutter API) from different threads. the Clutter threading model is based on taking a lock when using the API from any thread. the ideal approach would be not to call the Clutter API from different threads whenever it's possible - but use an idle handler set up with clutter_threads_add_idle(), as idle and timeout callbacks are called within the same thread that called clutter_main(). if this is not possible, safeguard the API calls using threads_enter() to lock the main mutex, and threads_leave() to unlock it. since Clutter threading model heavily borrows from GDK's one (we have the same issues, plus the fact that we need to safeguard the GL lock, which *must* be one per process), a good reading material is the GDK threading model description: http://library.gnome.org/devel/gdk/unstable/gdk-Threads.html hope this helps. ciao, Emmanuele. -- Emmanuele Bassi, OpenedHand Ltd. Unit R, Homesdale Business Centre 216-218 Homesdale Rd., Bromley - BR12QZ http://www.o-hand.com -- To unsubscribe send a mail to [EMAIL PROTECTED]
