Mainloop ownership



I have a Gtk widget library whose API can be called asynchronously.
Part of its implementation uses GConf, which I'm pretty sure
[http://developer.gnome.org/doc/API/gconf/c119.html] is intended only
to be used from a single thread.

I would like to make the async-safe API perform its work by making
direct calls when it's called from the Gtk mainloop thread, and
alternately by queueing an idle handler and waiting for a return
signal when the call comes from outside the mainloop thread.

If one is using a GMainLoop directly, you can test which thread you're
in by doing

 g_main_context_is_owner (g_main_loop_get_context (loop))

but gtkmain.c completely encapsulates the loop object (making the test
above impossible), and I'm a little stumped on how to determine
whether the caller is the Gtk main thread. Any ideas?

--Matt



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