Re: [gtk-list] gdk_thread_leave() in call back func, otherwise dead lock.
- From: Owen Taylor <otaylor redhat com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] gdk_thread_leave() in call back func, otherwise dead lock.
- Date: 18 Jan 2000 08:36:30 -0500
Yasushi Shoji <yashi@yashi.com> writes:
> Hi all,
>
> the following code will likely deadlocked, if I don't call
> gdk_thread_leave() before pthread_join(), because:
>
> from gtkfaq-5.html#ss5.2
> > Callbacks from GTK+ (signals) are made within the GTK+ lock.
>
> deadlock happnes:
>
> - loop_thread is waiting on sleep()
> - button is clicked and GDK_THREADS_ENTER() is called in
> gdk_event_dispatch() for callback function.
> - callback function calls pthread_join() and block itself to wait
> loop_thread.
> - loop_thread leaves sleep() and trys to GDK_THREADS_ENTER() but it's
> already locked by callback function and block itself
> - DEADLOCK!
>
>
> My question is:
>
> - Is it ok to call gdk_thread_leave() in call-back function, if the
> function does not call any gtk functions?
Yes, in this is fine. GTK+ is designed to be reentrant from within
callbacks.
If you try hard enough, especially if you connect to some of the more
"internal" signals of GTK+ like ::map, ::container_add, then you
might be able to break GTK+, but in general, it should be fine to
release (and then reacquire) the GDK lock in any callback you would
normally connect to.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]