diff options
author | Michael Meeks <michael.meeks@novell.com> | 2006-01-03 10:24:07 +0000 |
---|---|---|
committer | Michael Meeks <michael@src.gnome.org> | 2006-01-03 10:24:07 +0000 |
commit | d2555b65ee8d686c185a17e488bdbdb9753f1269 (patch) | |
tree | 0c38af0501887c5ffaa368dab52ca9c21e64667b | |
parent | a5a39466a1abe09141e3d51100b60661ea18e1c7 (diff) | |
download | glib-d2555b65ee8d686c185a17e488bdbdb9753f1269.tar.gz |
new method to determine if the current thread is the owner of the context.
2005-12-20 Michael Meeks <michael.meeks@novell.com>
* glib/gmain.c (g_main_context_is_owner): new method
to determine if the current thread is the owner of the
context.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 6 | ||||
-rw-r--r-- | glib/gmain.c | 30 |
4 files changed, 48 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2005-12-20 Michael Meeks <michael.meeks@novell.com> + + * glib/gmain.c (g_main_context_is_owner): new method + to determine if the current thread is the owner of the + context. + 2006-01-02 Matthias Clasen <mclasen@redhat.com> * glib/glib.symbols: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6fd5286d5..a1e9ba2ce 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2005-12-20 Michael Meeks <michael.meeks@novell.com> + + * glib/gmain.c (g_main_context_is_owner): new method + to determine if the current thread is the owner of the + context. + 2006-01-02 Matthias Clasen <mclasen@redhat.com> * glib/glib.symbols: diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 6fd5286d5..a1e9ba2ce 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +2005-12-20 Michael Meeks <michael.meeks@novell.com> + + * glib/gmain.c (g_main_context_is_owner): new method + to determine if the current thread is the owner of the + context. + 2006-01-02 Matthias Clasen <mclasen@redhat.com> * glib/glib.symbols: diff --git a/glib/gmain.c b/glib/gmain.c index 0595015d9..14e158aa1 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -3156,6 +3156,36 @@ g_main_context_wakeup (GMainContext *context) UNLOCK_CONTEXT (context); } +/** + * g_main_context_is_owner: + * @context: a #GMainContext + * + * Determines whether this thread holds the (recursive) + * ownership of this #GMaincontext. This is useful to + * know before waiting on another thread that may be + * blocking to get ownership of @context. + * + * Returns: TRUE if current thread is owner of @context. + **/ +gboolean +g_main_context_is_owner (GMainContext *context) +{ + gboolean is_owner; + + if (!context) + context = g_main_context_default (); + +#ifdef G_THREADS_ENABLED + LOCK_CONTEXT (context); + is_owner = context->owner == G_THREAD_SELF; + UNLOCK_CONTEXT (context); +#else + is_owner = TRUE; +#endif + + return is_owner; +} + /* Timeouts */ static void |