Commit 45714833 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Basic thread-awareness:

Fri May 15 21:16:54 1998  Owen Taylor  <otaylor@gtk.org>

	Basic thread-awareness:

	* acconfig.h configure.in: New option --with-threads=[yes/posix/no]

	* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
	gdk_threads_[init/enter/leave] for applications, plus
	gdk_threads_wake to wake the mainloop thread out of
	the select().

	* gtk/Makefile.am: gtk/testthreads.c: Test program for threads

Fri May 15 12:08:48 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/testgtk.c (list_clear): Account for the fact
	that gtk_list_clear_items is not inclusive. (Clears
	[start, end))
parent 123e299b
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
Fri May 15 21:16:54 1998 Owen Taylor <otaylor@gtk.org>
Basic thread-awareness:
* acconfig.h configure.in: New option --with-threads=[yes/posix/no]
* gdk/Makefile.am gdk/gdkthreads.c: Added new functions
gdk_threads_[init/enter/leave] for applications, plus
gdk_threads_wake to wake the mainloop thread out of
the select().
* gtk/Makefile.am: gtk/testthreads.c: Test program for threads
Fri May 15 12:08:48 1998 Owen Taylor <otaylor@gtk.org>
* gtk/testgtk.c (list_clear): Account for the fact
that gtk_list_clear_items is not inclusive. (Clears
[start, end))
Fri May 15 12:31:27 1998 rodo <doulik@karlin.mff.cuni.cz>
* gdk/gdk.c: include gdkkeysyms.h always
......
......@@ -31,6 +31,9 @@
#undef RESOURCE_BASE
/* Define to enable POSIX threading awareness */
#undef USE_PTHREADS
#undef XINPUT_NONE
#undef XINPUT_GXI
#undef XINPUT_XFREE
......
......@@ -32,6 +32,9 @@
#undef RESOURCE_BASE
/* Define to enable POSIX threading awareness */
#undef USE_PTHREADS
#undef XINPUT_NONE
#undef XINPUT_GXI
#undef XINPUT_XFREE
......
......@@ -68,6 +68,7 @@ AC_ARG_ENABLE(xim, [ --enable-xim support XIM [default=yes]],
AC_ARG_WITH(locale, [ --with-locale=LOCALE locale name you want to use ])
AC_ARG_WITH(xinput, [ --with-xinput=[no/gxi/xfree] support XInput ])
AC_ARG_WITH(threads, [ --with-threads=[posix] support threading ])
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
......@@ -183,6 +184,15 @@ else
AC_DEFINE(XINPUT_NONE)
fi
# Threads
if test "x$with_threads" = "xposix" || test "x$with_threads" = "xyes"; then
AC_CHECK_LIB(pthread, pthread_create,
AC_DEFINE(USE_PTHREADS)
x_libs="$x_libs -lpthread"
CFLAGS="$CFLAGS -D_REENTRANT")
fi
AC_SUBST(x_cflags)
AC_SUBST(x_includes)
AC_SUBST(x_ldflags)
......
......@@ -26,6 +26,7 @@ libgdk_1_1_la_SOURCES = \
gdkrectangle.c \
gdkregion.c \
gdkselection.c \
gdkthreads.c \
gdkvisual.c \
gdkwindow.c \
gdkxid.c \
......
......@@ -1606,8 +1606,31 @@ gdk_event_wait (void)
max_input = MAX (max_input, input->source);
}
#ifdef USE_PTHREADS
if (gdk_using_threads)
{
gdk_select_waiting = TRUE;
FD_SET (gdk_threads_pipe[0], &readfds);
max_input = MAX (max_input, gdk_threads_pipe[0]);
gdk_threads_leave ();
}
#endif
nfd = select (max_input+1, &readfds, &writefds, &exceptfds, timerp);
#ifdef USE_PTHREADS
if (gdk_using_threads)
{
gchar c;
gdk_threads_enter ();
gdk_select_waiting = FALSE;
if (FD_ISSET (gdk_threads_pipe[0], &readfds))
read (gdk_threads_pipe[0], &c, 1);
}
#endif
timerp = NULL;
timer_val = 0;
......
......@@ -801,6 +801,14 @@ GdkRegion* gdk_regions_subtract (GdkRegion *source1,
GdkRegion* gdk_regions_xor (GdkRegion *source1,
GdkRegion *source2);
gboolean gdk_threads_init (void);
void gdk_threads_enter (void);
void gdk_threads_leave (void);
/* If the mainloop thread is in its select, wake it up.
* For GTK's idle handling
*/
void gdk_threads_wake (void);
#ifdef __cplusplus
}
......
......@@ -20,6 +20,7 @@
#include <X11/Xlib.h>
#include "gdktypes.h"
#include "gdkprivate.h"
#include "../config.h"
guint gdk_debug_flags = 0;
gint gdk_use_xshm = TRUE;
......@@ -53,3 +54,13 @@ gint gdk_error_code;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GList *gdk_default_filters = NULL;
gboolean gdk_using_threads = FALSE;
/* Used to signal the mainloop thread from its select() */
#ifdef USE_PTHREADS
gint gdk_threads_pipe[2];
gboolean gdk_select_waiting = FALSE;
#endif
......@@ -268,6 +268,13 @@ extern gint gdk_error_code;
extern gint gdk_error_warnings;
extern gint gdk_null_window_warnings;
extern GList *gdk_default_filters;
extern gboolean gdk_using_threads;
/* Threading stuff */
#ifdef USE_PTHREADS
extern gint gdk_threads_pipe[2];
extern gboolean gdk_select_waiting;
#endif
/* Debugging support */
......
......@@ -20,6 +20,7 @@
#include <X11/Xlib.h>
#include "gdktypes.h"
#include "gdkprivate.h"
#include "../config.h"
guint gdk_debug_flags = 0;
gint gdk_use_xshm = TRUE;
......@@ -53,3 +54,13 @@ gint gdk_error_code;
gint gdk_error_warnings = TRUE;
gint gdk_null_window_warnings = TRUE;
GList *gdk_default_filters = NULL;
gboolean gdk_using_threads = FALSE;
/* Used to signal the mainloop thread from its select() */
#ifdef USE_PTHREADS
gint gdk_threads_pipe[2];
gboolean gdk_select_waiting = FALSE;
#endif
......@@ -1606,8 +1606,31 @@ gdk_event_wait (void)
max_input = MAX (max_input, input->source);
}
#ifdef USE_PTHREADS
if (gdk_using_threads)
{
gdk_select_waiting = TRUE;
FD_SET (gdk_threads_pipe[0], &readfds);
max_input = MAX (max_input, gdk_threads_pipe[0]);
gdk_threads_leave ();
}
#endif
nfd = select (max_input+1, &readfds, &writefds, &exceptfds, timerp);
#ifdef USE_PTHREADS
if (gdk_using_threads)
{
gchar c;
gdk_threads_enter ();
gdk_select_waiting = FALSE;
if (FD_ISSET (gdk_threads_pipe[0], &readfds))
read (gdk_threads_pipe[0], &c, 1);
}
#endif
timerp = NULL;
timer_val = 0;
......
......@@ -225,7 +225,7 @@ EXTRA_DIST = \
INCLUDES = -I$(top_srcdir) -I../glib -I$(top_srcdir)/glib @x_cflags@
noinst_PROGRAMS = testgtk testinput testselection simple
noinst_PROGRAMS = testgtk testinput testselection testthreads simple
# FIXME, we currently rely on linking against libglib-1.1
......@@ -243,11 +243,13 @@ LDADDS = \
testgtk_DEPENDENCIES = $(DEPS)
testinput_DEPENDENCIES = $(DEPS)
testthreads_DEPENDENCIES = $(DEPS)
testselection_DEPENDENCIES = $(DEPS)
simple_DEPENDENCIES = $(DEPS)
testgtk_LDADD = $(LDADDS)
testinput_LDADD = $(LDADDS)
testthreads_LDADD = $(LDADDS)
testselection_LDADD = $(LDADDS)
simple_LDADD = $(LDADDS)
......
......@@ -1052,7 +1052,14 @@ gtk_idle_add_full (gint priority,
idlef->data = data;
idlef->destroy = destroy;
/* If we are adding the first idle function, possibly wake up
* the main thread out of its select().
*/
if (!idle_functions)
gdk_threads_wake ();
idle_functions = g_list_insert_sorted (idle_functions, idlef, gtk_idle_compare);
return idlef->tag;
}
......
......@@ -2815,7 +2815,7 @@ static void
list_clear (GtkWidget *widget,
GtkWidget *list)
{
gtk_list_clear_items (GTK_LIST (list), 3 - 1, 5 - 1);
gtk_list_clear_items (GTK_LIST (list), 3 - 1, 6 - 1);
}
static void
......
......@@ -2815,7 +2815,7 @@ static void
list_clear (GtkWidget *widget,
GtkWidget *list)
{
gtk_list_clear_items (GTK_LIST (list), 3 - 1, 5 - 1);
gtk_list_clear_items (GTK_LIST (list), 3 - 1, 6 - 1);
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment