GMainContext foo ...



Hi guys,

	So - I've been trying to use the GMainContext to fix a rather tricky
issue in using unsafe single-threaded code accessed via ORBit2 from
multiple OO.o threads in a safe & reliable way. This is somewhat
involved, for various reasons, but made particularly unpleasant due to 2
missing methods:

	a) gboolean g_main_context_am_owner (void);
		+ this would tell you if the current thread owns the
		  g_main_context. NB. this is subtly different from
		  something like:
			if (g_main_context_acquire ()) {
				g_main_context_release();
				... I own it - horay ...
			}
		+ since that actually transiently takes ownership of
		  the thread but doesn't tell you if you (now) contine
		  to own it [ due to some (much) higher stack frame
		  having taken that lock ].

	b) void g_main_context_acquire_no_really_do_it (void);
		+ this cunning method - would be the analogue of
		  g_main_context_wait () - except instead of sitting
		  around hoping that the other thread doing the poll
		  will wake-up, it does a (safe) g_main_context_wakeup
		  with the relevant locks held;
		+ currently it appears impossible/acutely-ugly to
		  get ownership of the GMainContext from another thread
		  if the main thread is in it's poll.

	The basic reasoning here is that - ~all existing event-driven gtk+
code, typically happens from the default GMainContext, and/or at least
that provides a reasonable back-compatible way to create a backwards
compatible 'apartment' (by holding the GMainContext lock) to execute old
code in in-line.

	Anyway, hopefully that's useful to someone, although I guess I'm not
optimistic about these ever getting in - simple as they are ;-)

	If people are interested, I can knock up a simple patch too.

	HTH,

		Michael.

-- 
 michael meeks novell com  <><, Pseudo Engineer, itinerant idiot




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