summaryrefslogtreecommitdiff
path: root/gmain.c
diff options
context:
space:
mode:
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>2001-04-02 16:34:08 +0000
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>2001-04-02 16:34:08 +0000
commit7b06f826c942bf691b1fe6e52546ebcee3eecb5a (patch)
treea437c7c9cca4fb4c8dad9af014de3b8fc566ee8d /gmain.c
parent743f49cec9f4696c9eba32966d6ac78cd96c586d (diff)
downloadglib-7b06f826c942bf691b1fe6e52546ebcee3eecb5a.tar.gz
Use the new GRealThread member "context" instead of a GStaticPrivate to
2001-04-02 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gmain.c: Use the new GRealThread member "context" instead of a GStaticPrivate to store the thread specific main loop context. * gthread.c: Added "context" member to GRealThread and updated g_thread_create, g_thread_self and g_thread_cleanup accordingly. * gthread.c, gthread.h: Removed the functions g_static_private_(get|set)_for_thread and adapted g_static_private_(get|set) and g_static_private_free accordingly.
Diffstat (limited to 'gmain.c')
-rw-r--r--gmain.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/gmain.c b/gmain.c
index 6435a15ce..1fa20fe59 100644
--- a/gmain.c
+++ b/gmain.c
@@ -496,7 +496,7 @@ g_poll (GPollFD *fds,
/* Called to clean up when a thread terminates
*/
-static void
+void
g_main_context_destroy (GMainContext *context)
{
GSource *source;
@@ -538,6 +538,18 @@ g_main_context_destroy (GMainContext *context)
g_free (context);
}
+/* This is an imcomplete (only the members up till context) version of
+ * GRealThread from gthread.h. Keep them in sync */
+typedef struct _GRealThread GRealThread;
+struct _GRealThread
+{
+ GThread thread;
+ GThreadFunc func;
+ gpointer arg;
+ gpointer private_data;
+ GMainContext *context;
+};
+
/**
* g_main_context_get:
* @thread: a #GThread
@@ -551,13 +563,13 @@ g_main_context_destroy (GMainContext *context)
GMainContext *
g_main_context_get (GThread *thread)
{
- static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
+ GRealThread *real_thread = (GRealThread*)thread;
GMainContext *context;
g_return_val_if_fail (thread != NULL, NULL);
if (g_thread_supported ())
- context = g_static_private_get_for_thread (&private_key, thread);
+ context = real_thread->context;
else
context = default_main_context;
@@ -616,9 +628,7 @@ g_main_context_get (GThread *thread)
#endif
if (g_thread_supported ())
- g_static_private_set_for_thread (&private_key, thread,
- context,
- (GDestroyNotify)g_main_context_destroy);
+ real_thread->context = context;
else
default_main_context = context;
}