mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-19 16:52:11 +01:00
GMainContext useful in implementing some additional styles of main loop
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy): GMainContext useful in implementing some additional styles of main loop usage. To do this, however, Joe Hacker needs to be able to create/destroy GMainContext's at will. This is just an export of existing functionality, rather than new functionality. They are listed in the "Low level functions for implementing custom main loops" section of the header file, to avoid confusing people. * gobject/Makefile.am: . You have to 'touch oldest-source-stamp' if you want to avoid having the Makefile constantly rebuild itself. . Fix marshaller generation rules to work with srcdir != builddir (there were issues with trying to run "./glib-genmarshal", etc.)
This commit is contained in:
parent
4cdb98303b
commit
8f7579774c
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
@ -1,3 +1,14 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* gmain.c, gmain.h (g_main_context_new, g_main_context_destroy):
|
||||
GMainContext useful in implementing some additional styles of
|
||||
main loop usage. To do this, however, Joe Hacker needs to be able
|
||||
to create/destroy GMainContext's at will. This is just an export
|
||||
of existing functionality, rather than any new functionality.
|
||||
|
||||
They are listed in the "Low level functions for implementing custom
|
||||
main loops" section of the header file, to avoid confusing people.
|
||||
|
||||
Sun Dec 10 10:47:11 2000 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gmain.c (g_source_destroy_internal): Remove pollfds
|
||||
|
121
glib/gmain.c
121
glib/gmain.c
@ -485,9 +485,9 @@ g_poll (GPollFD *fds,
|
||||
|
||||
#endif /* !HAVE_POLL */
|
||||
|
||||
/* Called to clean up when a thread terminates
|
||||
/* Called to clean up, usually when a thread terminates
|
||||
*/
|
||||
static void
|
||||
void
|
||||
g_main_context_destroy (GMainContext *context)
|
||||
{
|
||||
GSource *source;
|
||||
@ -527,6 +527,73 @@ g_main_context_destroy (GMainContext *context)
|
||||
g_free (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_new:
|
||||
* @thread: a #GThread (may be NULL)
|
||||
*
|
||||
* This will create a main-loop context. The context will need to be destroyed
|
||||
* via g_main_context_destroy.
|
||||
*
|
||||
* Return value: a new main loop context.
|
||||
**/
|
||||
GMainContext *
|
||||
g_main_context_new(GThread *thread)
|
||||
{
|
||||
GMainContext *context;
|
||||
|
||||
context = g_new0 (GMainContext, 1);
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
context->mutex = g_mutex_new();
|
||||
|
||||
context->thread = thread;
|
||||
#endif
|
||||
|
||||
context->next_id = 1;
|
||||
|
||||
context->source_list = NULL;
|
||||
|
||||
#if HAVE_POLL
|
||||
context->poll_func = (GPollFunc)poll;
|
||||
#else
|
||||
context->poll_func = g_poll;
|
||||
#endif
|
||||
|
||||
context->cached_poll_array = NULL;
|
||||
context->cached_poll_array_size = 0;
|
||||
|
||||
context->pending_dispatches = g_ptr_array_new ();
|
||||
|
||||
context->time_is_current = FALSE;
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
if (pipe (context->wake_up_pipe) < 0)
|
||||
g_error ("Cannot create pipe main loop wake-up: %s\n",
|
||||
g_strerror (errno));
|
||||
|
||||
context->wake_up_rec.fd = context->wake_up_pipe[0];
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#else
|
||||
if ((context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL)) == NULL)
|
||||
g_error ("Cannot create wake-up semaphore: %s", g_win32_error_message (GetLastError ()));
|
||||
context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
|
||||
#endif
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_get:
|
||||
* @thread: a #GThread
|
||||
@ -552,55 +619,7 @@ g_main_context_get (GThread *thread)
|
||||
|
||||
if (!context)
|
||||
{
|
||||
context = g_new0 (GMainContext, 1);
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
context->mutex = g_mutex_new();
|
||||
|
||||
context->thread = thread;
|
||||
#endif
|
||||
|
||||
context->next_id = 1;
|
||||
|
||||
context->source_list = NULL;
|
||||
|
||||
#if HAVE_POLL
|
||||
context->poll_func = (GPollFunc)poll;
|
||||
#else
|
||||
context->poll_func = g_poll;
|
||||
#endif
|
||||
|
||||
context->cached_poll_array = NULL;
|
||||
context->cached_poll_array_size = 0;
|
||||
|
||||
context->pending_dispatches = g_ptr_array_new ();
|
||||
|
||||
context->time_is_current = FALSE;
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
if (pipe (context->wake_up_pipe) < 0)
|
||||
g_error ("Cannot create pipe main loop wake-up: %s\n",
|
||||
g_strerror (errno));
|
||||
|
||||
context->wake_up_rec.fd = context->wake_up_pipe[0];
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#else
|
||||
if ((context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL)) == NULL)
|
||||
g_error ("Cannot create wake-up semaphore: %s", g_win32_error_message (GetLastError ()));
|
||||
context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
|
||||
#endif
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
context = g_main_context_new (thread);
|
||||
|
||||
if (g_thread_supported ())
|
||||
g_static_private_set_for_thread (&private_key, thread,
|
||||
|
@ -143,6 +143,9 @@ GSource *g_main_context_find_source_by_funcs_user_data (GMainContext *conte
|
||||
|
||||
/* Low level functions for implementing custom main loops.
|
||||
*/
|
||||
GMainContext *g_main_context_new (GThread *thread);
|
||||
void g_main_context_destroy (GMainContext *context);
|
||||
|
||||
gboolean g_main_context_prepare (GMainContext *context,
|
||||
gint *priority);
|
||||
gint g_main_context_query (GMainContext *context,
|
||||
|
121
gmain.c
121
gmain.c
@ -485,9 +485,9 @@ g_poll (GPollFD *fds,
|
||||
|
||||
#endif /* !HAVE_POLL */
|
||||
|
||||
/* Called to clean up when a thread terminates
|
||||
/* Called to clean up, usually when a thread terminates
|
||||
*/
|
||||
static void
|
||||
void
|
||||
g_main_context_destroy (GMainContext *context)
|
||||
{
|
||||
GSource *source;
|
||||
@ -527,6 +527,73 @@ g_main_context_destroy (GMainContext *context)
|
||||
g_free (context);
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_new:
|
||||
* @thread: a #GThread (may be NULL)
|
||||
*
|
||||
* This will create a main-loop context. The context will need to be destroyed
|
||||
* via g_main_context_destroy.
|
||||
*
|
||||
* Return value: a new main loop context.
|
||||
**/
|
||||
GMainContext *
|
||||
g_main_context_new(GThread *thread)
|
||||
{
|
||||
GMainContext *context;
|
||||
|
||||
context = g_new0 (GMainContext, 1);
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
context->mutex = g_mutex_new();
|
||||
|
||||
context->thread = thread;
|
||||
#endif
|
||||
|
||||
context->next_id = 1;
|
||||
|
||||
context->source_list = NULL;
|
||||
|
||||
#if HAVE_POLL
|
||||
context->poll_func = (GPollFunc)poll;
|
||||
#else
|
||||
context->poll_func = g_poll;
|
||||
#endif
|
||||
|
||||
context->cached_poll_array = NULL;
|
||||
context->cached_poll_array_size = 0;
|
||||
|
||||
context->pending_dispatches = g_ptr_array_new ();
|
||||
|
||||
context->time_is_current = FALSE;
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
if (pipe (context->wake_up_pipe) < 0)
|
||||
g_error ("Cannot create pipe main loop wake-up: %s\n",
|
||||
g_strerror (errno));
|
||||
|
||||
context->wake_up_rec.fd = context->wake_up_pipe[0];
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#else
|
||||
if ((context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL)) == NULL)
|
||||
g_error ("Cannot create wake-up semaphore: %s", g_win32_error_message (GetLastError ()));
|
||||
context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
|
||||
#endif
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_main_context_get:
|
||||
* @thread: a #GThread
|
||||
@ -552,55 +619,7 @@ g_main_context_get (GThread *thread)
|
||||
|
||||
if (!context)
|
||||
{
|
||||
context = g_new0 (GMainContext, 1);
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
context->mutex = g_mutex_new();
|
||||
|
||||
context->thread = thread;
|
||||
#endif
|
||||
|
||||
context->next_id = 1;
|
||||
|
||||
context->source_list = NULL;
|
||||
|
||||
#if HAVE_POLL
|
||||
context->poll_func = (GPollFunc)poll;
|
||||
#else
|
||||
context->poll_func = g_poll;
|
||||
#endif
|
||||
|
||||
context->cached_poll_array = NULL;
|
||||
context->cached_poll_array_size = 0;
|
||||
|
||||
context->pending_dispatches = g_ptr_array_new ();
|
||||
|
||||
context->time_is_current = FALSE;
|
||||
|
||||
#ifdef G_THREADS_ENABLED
|
||||
if (g_thread_supported ())
|
||||
{
|
||||
#ifndef G_OS_WIN32
|
||||
if (pipe (context->wake_up_pipe) < 0)
|
||||
g_error ("Cannot create pipe main loop wake-up: %s\n",
|
||||
g_strerror (errno));
|
||||
|
||||
context->wake_up_rec.fd = context->wake_up_pipe[0];
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#else
|
||||
if ((context->wake_up_semaphore = CreateSemaphore (NULL, 0, 100, NULL)) == NULL)
|
||||
g_error ("Cannot create wake-up semaphore: %s", g_win32_error_message (GetLastError ()));
|
||||
context->wake_up_rec.fd = (gint) context->wake_up_semaphore;
|
||||
context->wake_up_rec.events = G_IO_IN;
|
||||
#ifdef G_MAIN_POLL_DEBUG
|
||||
g_print ("wake-up semaphore: %#x\n", (guint) context->wake_up_semaphore);
|
||||
#endif
|
||||
g_main_context_add_poll_unlocked (context, 0, &context->wake_up_rec);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
context = g_main_context_new (thread);
|
||||
|
||||
if (g_thread_supported ())
|
||||
g_static_private_set_for_thread (&private_key, thread,
|
||||
|
3
gmain.h
3
gmain.h
@ -143,6 +143,9 @@ GSource *g_main_context_find_source_by_funcs_user_data (GMainContext *conte
|
||||
|
||||
/* Low level functions for implementing custom main loops.
|
||||
*/
|
||||
GMainContext *g_main_context_new (GThread *thread);
|
||||
void g_main_context_destroy (GMainContext *context);
|
||||
|
||||
gboolean g_main_context_prepare (GMainContext *context,
|
||||
gint *priority);
|
||||
gint g_main_context_query (GMainContext *context,
|
||||
|
@ -1,3 +1,11 @@
|
||||
2000-12-12 Elliot Lee <sopwith@redhat.com>
|
||||
|
||||
* Makefile.am:
|
||||
. You have to 'touch oldest-source-stamp' if you want to avoid having
|
||||
the Makefile constantly rebuild itself.
|
||||
. Fix marshaller generation rules to work with srcdir != builddir
|
||||
(there were issues with trying to run "./glib-genmarshal", etc.)
|
||||
|
||||
Mon Dec 11 04:44:11 2000 Tim Janik <timj@gtk.org>
|
||||
|
||||
* gboxed.c: fixed dealing with collection/lcopy of NULL values.
|
||||
|
@ -102,7 +102,11 @@ EXTRA_DIST += $(gruntime_built_sources)
|
||||
gen_sources = xgen-gmh xgen-gmc xgen-gms
|
||||
CLEANFILES += $(gen_sources)
|
||||
Makefile: oldest-source-stamp # oh boy, does automake SUCK!
|
||||
|
||||
oldest-source-stamp: $(gruntime_built_sources)
|
||||
@touch oldest-source-stamp
|
||||
CLEANFILES+=oldest-source-stamp
|
||||
|
||||
$(OBJECTS): oldest-source-stamp ${gruntime_built_public_sources} # this is our oldest file, used for implicit auto-generation deps
|
||||
# initial creation of the real stamp-* files
|
||||
gmarshal.h: # never add deps here
|
||||
@ -114,24 +118,23 @@ gmarshal.h: # never add deps here
|
||||
# srcdir to be writable, passing --disable-rebuilds to
|
||||
# ../configure will supress all autogeneration rules.
|
||||
$(srcdir)/stamp-gmarshal.h: @REBUILD@ gmarshal.list gmarshal.h glib-genmarshal
|
||||
cd $(srcdir) \
|
||||
&& echo "#ifndef __G_MARSHAL_H__" > xgen-gmh \
|
||||
echo "#ifndef __G_MARSHAL_H__" > xgen-gmh \
|
||||
&& echo "#define __G_MARSHAL_H__" >> xgen-gmh \
|
||||
&& ./glib-genmarshal --nostdinc --prefix=g_cclosure_marshal gmarshal.list --header >> xgen-gmh \
|
||||
&& ./glib-genmarshal --nostdinc --prefix=g_cclosure_marshal $(srcdir)/gmarshal.list --header >> xgen-gmh \
|
||||
&& echo "#endif /* __G_MARSHAL_H__ */" >> xgen-gmh \
|
||||
&& (cmp -s xgen-gmh gmarshal.h || cp xgen-gmh gmarshal.h) \
|
||||
&& (cmp -s xgen-gmh $(srcdir)/gmarshal.h || cp xgen-gmh $(srcdir)/gmarshal.h) \
|
||||
&& rm -f xgen-gmh xgen-gmh~ \
|
||||
&& echo timestamp > $(@F)
|
||||
&& echo timestamp > $@
|
||||
|
||||
$(srcdir)/gmarshal.c: @REBUILD@ $(srcdir)/stamp-gmarshal.h
|
||||
cd $(srcdir) \
|
||||
&& ./glib-genmarshal --nostdinc --prefix=g_cclosure_marshal gmarshal.list --body >> xgen-gmc \
|
||||
&& cp xgen-gmc gmarshal.c \
|
||||
./glib-genmarshal --nostdinc --prefix=g_cclosure_marshal $(srcdir)/gmarshal.list --body >> xgen-gmc \
|
||||
&& cp xgen-gmc $(srcdir)/gmarshal.c \
|
||||
&& rm -f xgen-gmc xgen-gmc~
|
||||
|
||||
$(srcdir)/gmarshal.strings: @REBUILD@ $(srcdir)/gmarshal.list
|
||||
cd $(srcdir) \
|
||||
&& grep '^[A-Z]' $(srcdir)/gmarshal.list \
|
||||
grep '^[A-Z]' $(srcdir)/gmarshal.list \
|
||||
| sed -e 's/^/"g_cclosure_marshal_/' -e 's/:/__/' -e 's/,/_/g' -e 's/$$/",/' > xgen-gms \
|
||||
&& cp xgen-gms gmarshal.strings \
|
||||
&& cp xgen-gms $(srcdir)/gmarshal.strings \
|
||||
&& rm -f xgen-gms xgen-gms~
|
||||
glib-genmarshal.o: gmarshal.strings
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user