Re: gdk_threads_enter/leave() in threaded and non threaded situation
- From: Peter Bloomfield <PeterBloomfield BellSouth net>
- To: Stefan Kost <ensonic hora-obscura de>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gdk_threads_enter/leave() in threaded and non threaded situation
- Date: Thu, 10 Feb 2005 22:02:06 +0000
On 2005.02.10 16:20, Stefan Kost wrote:
hi hi,
I have a gobject property that is set (via g_object_set()) from
within a thread and from the main thread.
Further I have signal handlers that watch this via
notify::property.
These signal handler call gtk functions. Therefore in these
signal handlers the gtk part is wrapped with gdk_threads_enter/
leave().
When the singnal is triggered from the thread it works, but
when it gets triggerd from the main thread gdk_threads_enter
blocks.
This is quite obvious, as in this thread I am already in
gdk_threads_enter(). But how should the signal handler know
that (wheter it has been triggered from the main thread or from
another thread)?
You *could* store your main thread id on startup, and compare it
with the current thread id in the handler...but that depends on
the assumption that the main thread is always locked and a
subthread is always unlocked, which might be true now but jump up
and bite you later.
Safer is to use gdk_threads_set_lock_functions to replace the
standard self-blocking lock with a sensible recursive lock, and
forget about which thread it is!
Peter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]