Re: Threads



Russell Shaw wrote:

ok. I also have a function that is called from a normal gtk callback, as
well as other threads. This function calls gtk things, so it has
gtk_threads_enter()/gtk_threads_leave() in it.

You should not call gdk_threads_enter in almost all callbacks. There're few situations (timeouts, for example), when callback runs outside the global lock and you have to
protect your code.

When the function is called from the normal gtk callback, it gets blocked
on gtk_threads_enter(). Why? I have disabled all other threads.

That's what 'fast' pthread mutexes do. If the 'fast' mutex is locked you'll get blocked on it on second lock even from the lock-owner thread. GDK -> Glib's mutex -> pthread
(LinuxThreads) mutex == 'fast' default mutex.

I fixed it by doing: gdk_threads_leave() -> function() -> gdk_threads_enter()
from within the gtk thread.

Yes, it's normal practice if you turned to call protected code.

   Olexiy




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