2002-07-04 17:19:30 +02:00
|
|
|
#undef G_DISABLE_ASSERT
|
|
|
|
#undef G_LOG_DOMAIN
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
/* GMutex */
|
|
|
|
|
|
|
|
static GMutex* test_g_mutex_mutex = NULL;
|
|
|
|
static guint test_g_mutex_int = 0;
|
2002-02-15 10:58:49 +01:00
|
|
|
static gboolean test_g_mutex_thread_ready;
|
2000-04-19 11:29:19 +02:00
|
|
|
G_LOCK_DEFINE_STATIC (test_g_mutex);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
|
2001-05-08 10:23:18 +02:00
|
|
|
static gpointer
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_mutex_thread (gpointer data)
|
|
|
|
{
|
|
|
|
g_assert (GPOINTER_TO_INT (data) == 42);
|
|
|
|
g_assert (g_mutex_trylock (test_g_mutex_mutex) == FALSE);
|
2000-04-19 11:29:19 +02:00
|
|
|
g_assert (G_TRYLOCK (test_g_mutex) == FALSE);
|
2002-02-15 10:58:49 +01:00
|
|
|
test_g_mutex_thread_ready = TRUE;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_mutex_lock (test_g_mutex_mutex);
|
|
|
|
g_assert (test_g_mutex_int == 42);
|
|
|
|
g_mutex_unlock (test_g_mutex_mutex);
|
2001-05-08 10:23:18 +02:00
|
|
|
|
|
|
|
return GINT_TO_POINTER (41);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_g_mutex (void)
|
|
|
|
{
|
|
|
|
GThread *thread;
|
|
|
|
test_g_mutex_mutex = g_mutex_new ();
|
|
|
|
|
|
|
|
g_assert (g_mutex_trylock (test_g_mutex_mutex));
|
2000-04-19 11:29:19 +02:00
|
|
|
g_assert (G_TRYLOCK (test_g_mutex));
|
2002-02-15 10:58:49 +01:00
|
|
|
test_g_mutex_thread_ready = FALSE;
|
2001-05-18 10:44:57 +02:00
|
|
|
thread = g_thread_create (test_g_mutex_thread, GINT_TO_POINTER (42),
|
|
|
|
TRUE, NULL);
|
2002-02-15 10:58:49 +01:00
|
|
|
/* This busy wait is only for testing purposes and not an example of
|
|
|
|
* good code!*/
|
|
|
|
while (!test_g_mutex_thread_ready)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_mutex_int = 42;
|
2000-04-19 11:29:19 +02:00
|
|
|
G_UNLOCK (test_g_mutex);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_mutex_unlock (test_g_mutex_mutex);
|
2001-05-08 10:23:18 +02:00
|
|
|
g_assert (GPOINTER_TO_INT (g_thread_join (thread)) == 41);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_mutex_free (test_g_mutex_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GStaticRecMutex */
|
|
|
|
|
|
|
|
static GStaticRecMutex test_g_static_rec_mutex_mutex = G_STATIC_REC_MUTEX_INIT;
|
|
|
|
static guint test_g_static_rec_mutex_int = 0;
|
2002-02-15 10:58:49 +01:00
|
|
|
static gboolean test_g_static_rec_mutex_thread_ready;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
|
2001-05-08 10:23:18 +02:00
|
|
|
static gpointer
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_static_rec_mutex_thread (gpointer data)
|
|
|
|
{
|
|
|
|
g_assert (GPOINTER_TO_INT (data) == 42);
|
|
|
|
g_assert (g_static_rec_mutex_trylock (&test_g_static_rec_mutex_mutex)
|
|
|
|
== FALSE);
|
2002-02-15 10:58:49 +01:00
|
|
|
test_g_static_rec_mutex_thread_ready = TRUE;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_static_rec_mutex_lock (&test_g_static_rec_mutex_mutex);
|
|
|
|
g_static_rec_mutex_lock (&test_g_static_rec_mutex_mutex);
|
|
|
|
g_assert (test_g_static_rec_mutex_int == 42);
|
2002-02-15 10:58:49 +01:00
|
|
|
test_g_static_rec_mutex_thread_ready = FALSE;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
|
|
|
|
g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
|
2001-05-08 10:23:18 +02:00
|
|
|
|
|
|
|
g_thread_exit (GINT_TO_POINTER (43));
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
return NULL;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_g_static_rec_mutex (void)
|
|
|
|
{
|
|
|
|
GThread *thread;
|
|
|
|
|
|
|
|
g_assert (g_static_rec_mutex_trylock (&test_g_static_rec_mutex_mutex));
|
2002-02-15 10:58:49 +01:00
|
|
|
test_g_static_rec_mutex_thread_ready = FALSE;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
thread = g_thread_create (test_g_static_rec_mutex_thread,
|
2001-05-18 10:44:57 +02:00
|
|
|
GINT_TO_POINTER (42), TRUE, NULL);
|
2002-02-15 10:58:49 +01:00
|
|
|
/* This busy wait is only for testing purposes and not an example of
|
|
|
|
* good code!*/
|
|
|
|
while (!test_g_static_rec_mutex_thread_ready)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_assert (g_static_rec_mutex_trylock (&test_g_static_rec_mutex_mutex));
|
|
|
|
test_g_static_rec_mutex_int = 41;
|
|
|
|
g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
|
|
|
|
test_g_static_rec_mutex_int = 42;
|
|
|
|
g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
|
2002-02-15 10:58:49 +01:00
|
|
|
|
|
|
|
/* This busy wait is only for testing purposes and not an example of
|
|
|
|
* good code!*/
|
|
|
|
while (test_g_static_rec_mutex_thread_ready)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_static_rec_mutex_lock (&test_g_static_rec_mutex_mutex);
|
|
|
|
test_g_static_rec_mutex_int = 0;
|
|
|
|
g_static_rec_mutex_unlock (&test_g_static_rec_mutex_mutex);
|
2001-05-08 10:23:18 +02:00
|
|
|
|
|
|
|
g_assert (GPOINTER_TO_INT (g_thread_join (thread)) == 43);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* GStaticPrivate */
|
|
|
|
|
|
|
|
#define THREADS 10
|
|
|
|
|
2001-02-13 16:57:44 +01:00
|
|
|
static GStaticPrivate test_g_static_private_private1 = G_STATIC_PRIVATE_INIT;
|
|
|
|
static GStaticPrivate test_g_static_private_private2 = G_STATIC_PRIVATE_INIT;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
static GStaticMutex test_g_static_private_mutex = G_STATIC_MUTEX_INIT;
|
|
|
|
static guint test_g_static_private_counter = 0;
|
2001-02-13 16:57:44 +01:00
|
|
|
static guint test_g_static_private_ready = 0;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
|
|
|
|
static gpointer
|
|
|
|
test_g_static_private_constructor (void)
|
|
|
|
{
|
|
|
|
g_static_mutex_lock (&test_g_static_private_mutex);
|
|
|
|
test_g_static_private_counter++;
|
|
|
|
g_static_mutex_unlock (&test_g_static_private_mutex);
|
|
|
|
return g_new (guint,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_g_static_private_destructor (gpointer data)
|
|
|
|
{
|
|
|
|
g_static_mutex_lock (&test_g_static_private_mutex);
|
|
|
|
test_g_static_private_counter--;
|
|
|
|
g_static_mutex_unlock (&test_g_static_private_mutex);
|
|
|
|
g_free (data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-08 10:23:18 +02:00
|
|
|
static gpointer
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_static_private_thread (gpointer data)
|
|
|
|
{
|
|
|
|
guint number = GPOINTER_TO_INT (data);
|
|
|
|
guint i;
|
2001-02-13 16:57:44 +01:00
|
|
|
guint *private1, *private2;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
number = number * 11 + 1; /* A very simple and bad RNG ;-) */
|
2001-02-13 16:57:44 +01:00
|
|
|
private1 = g_static_private_get (&test_g_static_private_private1);
|
|
|
|
if (!private1 || number % 7 > 3)
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
{
|
2001-02-13 16:57:44 +01:00
|
|
|
private1 = test_g_static_private_constructor ();
|
|
|
|
g_static_private_set (&test_g_static_private_private1, private1,
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_static_private_destructor);
|
|
|
|
}
|
2001-02-13 16:57:44 +01:00
|
|
|
*private1 = number;
|
|
|
|
private2 = g_static_private_get (&test_g_static_private_private2);
|
|
|
|
if (!private2 || number % 13 > 5)
|
|
|
|
{
|
|
|
|
private2 = test_g_static_private_constructor ();
|
|
|
|
g_static_private_set (&test_g_static_private_private2, private2,
|
|
|
|
test_g_static_private_destructor);
|
|
|
|
}
|
|
|
|
*private2 = number * 2;
|
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
|
|
|
g_assert (number == *private1);
|
|
|
|
g_assert (number * 2 == *private2);
|
|
|
|
}
|
|
|
|
g_static_mutex_lock (&test_g_static_private_mutex);
|
|
|
|
test_g_static_private_ready++;
|
|
|
|
g_static_mutex_unlock (&test_g_static_private_mutex);
|
|
|
|
|
|
|
|
/* Busy wait is not nice but that's just a test */
|
|
|
|
while (test_g_static_private_ready != 0)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
|
|
|
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
{
|
|
|
|
private2 = g_static_private_get (&test_g_static_private_private2);
|
|
|
|
number = number * 11 + 1; /* A very simple and bad RNG ;-) */
|
|
|
|
if (!private2 || number % 13 > 5)
|
|
|
|
{
|
|
|
|
private2 = test_g_static_private_constructor ();
|
|
|
|
g_static_private_set (&test_g_static_private_private2, private2,
|
|
|
|
test_g_static_private_destructor);
|
|
|
|
}
|
|
|
|
*private2 = number * 2;
|
2000-09-06 15:56:17 +02:00
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
2001-02-13 16:57:44 +01:00
|
|
|
g_assert (number * 2 == *private2);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
2001-05-08 10:23:18 +02:00
|
|
|
|
|
|
|
return GINT_TO_POINTER (GPOINTER_TO_INT (data) * 3);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_g_static_private (void)
|
|
|
|
{
|
|
|
|
GThread *threads[THREADS];
|
|
|
|
guint i;
|
2001-02-13 16:57:44 +01:00
|
|
|
|
|
|
|
test_g_static_private_ready = 0;
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
for (i = 0; i < THREADS; i++)
|
|
|
|
{
|
|
|
|
threads[i] = g_thread_create (test_g_static_private_thread,
|
2001-05-18 10:44:57 +02:00
|
|
|
GINT_TO_POINTER (i), TRUE, NULL);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
2001-02-13 16:57:44 +01:00
|
|
|
|
|
|
|
/* Busy wait is not nice but that's just a test */
|
|
|
|
while (test_g_static_private_ready != THREADS)
|
|
|
|
g_usleep (G_USEC_PER_SEC / 5);
|
|
|
|
|
|
|
|
/* Reuse the static private */
|
|
|
|
g_static_private_free (&test_g_static_private_private2);
|
|
|
|
g_static_private_init (&test_g_static_private_private2);
|
|
|
|
|
|
|
|
test_g_static_private_ready = 0;
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
for (i = 0; i < THREADS; i++)
|
2001-05-08 10:23:18 +02:00
|
|
|
g_assert (GPOINTER_TO_INT (g_thread_join (threads[i])) == i * 3);
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
g_assert (test_g_static_private_counter == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GStaticRWLock */
|
|
|
|
|
|
|
|
/* -1 = writing; >0 = # of readers */
|
|
|
|
static gint test_g_static_rw_lock_state = 0;
|
|
|
|
G_LOCK_DEFINE (test_g_static_rw_lock_state);
|
|
|
|
|
|
|
|
static gboolean test_g_static_rw_lock_run = TRUE;
|
|
|
|
static GStaticRWLock test_g_static_rw_lock_lock = G_STATIC_RW_LOCK_INIT;
|
|
|
|
|
2001-05-08 10:23:18 +02:00
|
|
|
static gpointer
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_static_rw_lock_thread (gpointer data)
|
|
|
|
{
|
|
|
|
while (test_g_static_rw_lock_run)
|
|
|
|
{
|
|
|
|
if (g_random_double() > .2) /* I'm a reader */
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g_random_double() > .2) /* I'll block */
|
|
|
|
g_static_rw_lock_reader_lock (&test_g_static_rw_lock_lock);
|
|
|
|
else /* I'll only try */
|
|
|
|
if (!g_static_rw_lock_reader_trylock (&test_g_static_rw_lock_lock))
|
|
|
|
continue;
|
|
|
|
G_LOCK (test_g_static_rw_lock_state);
|
|
|
|
g_assert (test_g_static_rw_lock_state >= 0);
|
|
|
|
test_g_static_rw_lock_state++;
|
|
|
|
G_UNLOCK (test_g_static_rw_lock_state);
|
|
|
|
|
2002-02-15 10:58:49 +01:00
|
|
|
g_usleep (g_random_int_range (20,1000));
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
|
|
|
|
G_LOCK (test_g_static_rw_lock_state);
|
|
|
|
test_g_static_rw_lock_state--;
|
|
|
|
G_UNLOCK (test_g_static_rw_lock_state);
|
|
|
|
|
|
|
|
g_static_rw_lock_reader_unlock (&test_g_static_rw_lock_lock);
|
|
|
|
}
|
|
|
|
else /* I'm a writer */
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g_random_double() > .2) /* I'll block */
|
|
|
|
g_static_rw_lock_writer_lock (&test_g_static_rw_lock_lock);
|
|
|
|
else /* I'll only try */
|
|
|
|
if (!g_static_rw_lock_writer_trylock (&test_g_static_rw_lock_lock))
|
|
|
|
continue;
|
|
|
|
G_LOCK (test_g_static_rw_lock_state);
|
|
|
|
g_assert (test_g_static_rw_lock_state == 0);
|
|
|
|
test_g_static_rw_lock_state = -1;
|
|
|
|
G_UNLOCK (test_g_static_rw_lock_state);
|
|
|
|
|
2002-02-15 10:58:49 +01:00
|
|
|
g_usleep (g_random_int_range (20,1000));
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
|
|
|
|
G_LOCK (test_g_static_rw_lock_state);
|
|
|
|
test_g_static_rw_lock_state = 0;
|
|
|
|
G_UNLOCK (test_g_static_rw_lock_state);
|
|
|
|
|
|
|
|
g_static_rw_lock_writer_unlock (&test_g_static_rw_lock_lock);
|
|
|
|
}
|
|
|
|
}
|
2001-05-08 10:23:18 +02:00
|
|
|
return NULL;
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_g_static_rw_lock ()
|
|
|
|
{
|
|
|
|
GThread *threads[THREADS];
|
|
|
|
guint i;
|
|
|
|
for (i = 0; i < THREADS; i++)
|
|
|
|
{
|
|
|
|
threads[i] = g_thread_create (test_g_static_rw_lock_thread,
|
2001-05-18 10:44:57 +02:00
|
|
|
NULL, TRUE, NULL);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
}
|
2002-02-15 10:58:49 +01:00
|
|
|
g_usleep (G_USEC_PER_SEC * 5);
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
test_g_static_rw_lock_run = FALSE;
|
|
|
|
for (i = 0; i < THREADS; i++)
|
|
|
|
{
|
|
|
|
g_thread_join (threads[i]);
|
|
|
|
}
|
|
|
|
g_assert (test_g_static_rw_lock_state == 0);
|
|
|
|
}
|
|
|
|
|
2003-07-09 01:43:48 +02:00
|
|
|
#define G_ONCE_SIZE 100
|
|
|
|
#define G_ONCE_THREADS 10
|
|
|
|
|
|
|
|
G_LOCK_DEFINE (test_g_once);
|
|
|
|
static guint test_g_once_guint_array[G_ONCE_SIZE];
|
|
|
|
static GOnce test_g_once_array[G_ONCE_SIZE];
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
test_g_once_init_func(gpointer arg)
|
|
|
|
{
|
|
|
|
guint *count = arg;
|
|
|
|
g_usleep (g_random_int_range (20,1000));
|
|
|
|
(*count)++;
|
|
|
|
g_usleep (g_random_int_range (20,1000));
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
test_g_once_thread (gpointer ignore)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
G_LOCK (test_g_once);
|
|
|
|
/* Don't start before all threads are created */
|
|
|
|
G_UNLOCK (test_g_once);
|
|
|
|
for (i = 0; i < 1000; i++)
|
|
|
|
{
|
|
|
|
guint pos = g_random_int_range (0, G_ONCE_SIZE);
|
|
|
|
gpointer ret = g_once (test_g_once_array + pos, test_g_once_init_func,
|
|
|
|
test_g_once_guint_array + pos);
|
|
|
|
g_assert (ret == test_g_once_guint_array + pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure, that all counters are touched at least once */
|
|
|
|
for (i = 0; i < G_ONCE_SIZE; i++)
|
|
|
|
{
|
|
|
|
gpointer ret = g_once (test_g_once_array + i, test_g_once_init_func,
|
|
|
|
test_g_once_guint_array + i);
|
|
|
|
g_assert (ret == test_g_once_guint_array + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_g_thread_once (void)
|
|
|
|
{
|
|
|
|
static GOnce once_init = G_ONCE_INIT;
|
|
|
|
GThread *threads[G_ONCE_THREADS];
|
|
|
|
guint i;
|
|
|
|
for (i = 0; i < G_ONCE_SIZE; i++)
|
|
|
|
{
|
|
|
|
test_g_once_array[i] = once_init;
|
|
|
|
test_g_once_guint_array[i] = i;
|
|
|
|
}
|
|
|
|
G_LOCK (test_g_once);
|
|
|
|
for (i = 0; i < G_ONCE_THREADS; i++)
|
|
|
|
{
|
|
|
|
threads[i] = g_thread_create (test_g_once_thread, (gpointer)(i%2),
|
|
|
|
TRUE, NULL);
|
|
|
|
}
|
|
|
|
G_UNLOCK (test_g_once);
|
|
|
|
for (i = 0; i < G_ONCE_THREADS; i++)
|
|
|
|
{
|
|
|
|
g_thread_join (threads[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < G_ONCE_SIZE; i++)
|
|
|
|
{
|
|
|
|
g_assert (test_g_once_guint_array[i] == i + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
/* run all the tests */
|
Added the missing POSIX_NO_YIELD and POSIX_NO_PRIORITIES warning messages.
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Added the missing POSIX_NO_YIELD and
POSIX_NO_PRIORITIES warning messages.
* configure.in: Use AC_TRY_RUN instead of AC_TRY_LINK, to test for
real thread support. On solaris pthread_create can be linked to
even in -lc, but it doesn't work then.
* configure.in: Don't use priorities for threads, when the
minimal/maximal priorities couldn't be determined at configure
time.
* configure.in, gthread.c: Always define GSystemThread in
glibconfig.h to represent a system thread.
* configure.in: Do not use native recursive threads, when
possibe. We use some features, that they do not expose (namely the
depth counter).
* glib.h, gthread.c: Redefined GStaticRecMutex. The functions are
now implemented in a different way, which should be way
faster. Alsothere are now functions g_static_rec_mutex_unlock_full
and g_static_rec_mutex_lock_full to leave/enter a recursive mutex
completly.
* gthread.c (g_thread_self): Do not test the system_thread to be
non-zero to speed things up.
* gthread.c (g_mutex_init): Therefore set the system_thread of the
main thread here.
* tests/thread-test.c: Rerun all tests once again, but this time
we fool the system into thinking, that the available thread system
is not native, but userprovided.
* gthread/gthread-posix.c: Don't use priorities for threads,
when the minimal/maximal priorities couldn't be determined at
configure time.
* gthread/gthread-posix.c: Don't check for errors, when
setting the scope of a tread to system, as some posix
implementations can't do that and we don't want the thing to
fail because of that.
2000-03-17 15:49:59 +01:00
|
|
|
void
|
|
|
|
run_all_tests()
|
|
|
|
{
|
|
|
|
test_g_mutex ();
|
2003-07-09 01:43:48 +02:00
|
|
|
g_print (".");
|
Added the missing POSIX_NO_YIELD and POSIX_NO_PRIORITIES warning messages.
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Added the missing POSIX_NO_YIELD and
POSIX_NO_PRIORITIES warning messages.
* configure.in: Use AC_TRY_RUN instead of AC_TRY_LINK, to test for
real thread support. On solaris pthread_create can be linked to
even in -lc, but it doesn't work then.
* configure.in: Don't use priorities for threads, when the
minimal/maximal priorities couldn't be determined at configure
time.
* configure.in, gthread.c: Always define GSystemThread in
glibconfig.h to represent a system thread.
* configure.in: Do not use native recursive threads, when
possibe. We use some features, that they do not expose (namely the
depth counter).
* glib.h, gthread.c: Redefined GStaticRecMutex. The functions are
now implemented in a different way, which should be way
faster. Alsothere are now functions g_static_rec_mutex_unlock_full
and g_static_rec_mutex_lock_full to leave/enter a recursive mutex
completly.
* gthread.c (g_thread_self): Do not test the system_thread to be
non-zero to speed things up.
* gthread.c (g_mutex_init): Therefore set the system_thread of the
main thread here.
* tests/thread-test.c: Rerun all tests once again, but this time
we fool the system into thinking, that the available thread system
is not native, but userprovided.
* gthread/gthread-posix.c: Don't use priorities for threads,
when the minimal/maximal priorities couldn't be determined at
configure time.
* gthread/gthread-posix.c: Don't check for errors, when
setting the scope of a tread to system, as some posix
implementations can't do that and we don't want the thing to
fail because of that.
2000-03-17 15:49:59 +01:00
|
|
|
test_g_static_rec_mutex ();
|
2003-07-09 01:43:48 +02:00
|
|
|
g_print (".");
|
Added the missing POSIX_NO_YIELD and POSIX_NO_PRIORITIES warning messages.
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Added the missing POSIX_NO_YIELD and
POSIX_NO_PRIORITIES warning messages.
* configure.in: Use AC_TRY_RUN instead of AC_TRY_LINK, to test for
real thread support. On solaris pthread_create can be linked to
even in -lc, but it doesn't work then.
* configure.in: Don't use priorities for threads, when the
minimal/maximal priorities couldn't be determined at configure
time.
* configure.in, gthread.c: Always define GSystemThread in
glibconfig.h to represent a system thread.
* configure.in: Do not use native recursive threads, when
possibe. We use some features, that they do not expose (namely the
depth counter).
* glib.h, gthread.c: Redefined GStaticRecMutex. The functions are
now implemented in a different way, which should be way
faster. Alsothere are now functions g_static_rec_mutex_unlock_full
and g_static_rec_mutex_lock_full to leave/enter a recursive mutex
completly.
* gthread.c (g_thread_self): Do not test the system_thread to be
non-zero to speed things up.
* gthread.c (g_mutex_init): Therefore set the system_thread of the
main thread here.
* tests/thread-test.c: Rerun all tests once again, but this time
we fool the system into thinking, that the available thread system
is not native, but userprovided.
* gthread/gthread-posix.c: Don't use priorities for threads,
when the minimal/maximal priorities couldn't be determined at
configure time.
* gthread/gthread-posix.c: Don't check for errors, when
setting the scope of a tread to system, as some posix
implementations can't do that and we don't want the thing to
fail because of that.
2000-03-17 15:49:59 +01:00
|
|
|
test_g_static_private ();
|
2003-07-09 01:43:48 +02:00
|
|
|
g_print (".");
|
2001-02-13 16:57:44 +01:00
|
|
|
test_g_static_rw_lock ();
|
2003-07-09 01:43:48 +02:00
|
|
|
g_print (".");
|
|
|
|
test_g_thread_once ();
|
|
|
|
g_print (".");
|
Added the missing POSIX_NO_YIELD and POSIX_NO_PRIORITIES warning messages.
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Added the missing POSIX_NO_YIELD and
POSIX_NO_PRIORITIES warning messages.
* configure.in: Use AC_TRY_RUN instead of AC_TRY_LINK, to test for
real thread support. On solaris pthread_create can be linked to
even in -lc, but it doesn't work then.
* configure.in: Don't use priorities for threads, when the
minimal/maximal priorities couldn't be determined at configure
time.
* configure.in, gthread.c: Always define GSystemThread in
glibconfig.h to represent a system thread.
* configure.in: Do not use native recursive threads, when
possibe. We use some features, that they do not expose (namely the
depth counter).
* glib.h, gthread.c: Redefined GStaticRecMutex. The functions are
now implemented in a different way, which should be way
faster. Alsothere are now functions g_static_rec_mutex_unlock_full
and g_static_rec_mutex_lock_full to leave/enter a recursive mutex
completly.
* gthread.c (g_thread_self): Do not test the system_thread to be
non-zero to speed things up.
* gthread.c (g_mutex_init): Therefore set the system_thread of the
main thread here.
* tests/thread-test.c: Rerun all tests once again, but this time
we fool the system into thinking, that the available thread system
is not native, but userprovided.
* gthread/gthread-posix.c: Don't use priorities for threads,
when the minimal/maximal priorities couldn't be determined at
configure time.
* gthread/gthread-posix.c: Don't check for errors, when
setting the scope of a tread to system, as some posix
implementations can't do that and we don't want the thing to
fail because of that.
2000-03-17 15:49:59 +01:00
|
|
|
}
|
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char *argv[])
|
|
|
|
{
|
|
|
|
/* Only run the test, if threads are enabled and a default thread
|
|
|
|
implementation is available */
|
|
|
|
#if defined(G_THREADS_ENABLED) && ! defined(G_THREADS_IMPL_NONE)
|
|
|
|
g_thread_init (NULL);
|
Added the missing POSIX_NO_YIELD and POSIX_NO_PRIORITIES warning messages.
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Added the missing POSIX_NO_YIELD and
POSIX_NO_PRIORITIES warning messages.
* configure.in: Use AC_TRY_RUN instead of AC_TRY_LINK, to test for
real thread support. On solaris pthread_create can be linked to
even in -lc, but it doesn't work then.
* configure.in: Don't use priorities for threads, when the
minimal/maximal priorities couldn't be determined at configure
time.
* configure.in, gthread.c: Always define GSystemThread in
glibconfig.h to represent a system thread.
* configure.in: Do not use native recursive threads, when
possibe. We use some features, that they do not expose (namely the
depth counter).
* glib.h, gthread.c: Redefined GStaticRecMutex. The functions are
now implemented in a different way, which should be way
faster. Alsothere are now functions g_static_rec_mutex_unlock_full
and g_static_rec_mutex_lock_full to leave/enter a recursive mutex
completly.
* gthread.c (g_thread_self): Do not test the system_thread to be
non-zero to speed things up.
* gthread.c (g_mutex_init): Therefore set the system_thread of the
main thread here.
* tests/thread-test.c: Rerun all tests once again, but this time
we fool the system into thinking, that the available thread system
is not native, but userprovided.
* gthread/gthread-posix.c: Don't use priorities for threads,
when the minimal/maximal priorities couldn't be determined at
configure time.
* gthread/gthread-posix.c: Don't check for errors, when
setting the scope of a tread to system, as some posix
implementations can't do that and we don't want the thing to
fail because of that.
2000-03-17 15:49:59 +01:00
|
|
|
run_all_tests ();
|
|
|
|
|
|
|
|
/* Now we rerun all tests, but this time we fool the system into
|
|
|
|
* thinking, that the available thread system is not native, but
|
|
|
|
* userprovided. */
|
|
|
|
|
|
|
|
g_thread_use_default_impl = FALSE;
|
|
|
|
run_all_tests ();
|
2003-07-09 01:43:48 +02:00
|
|
|
g_print ("\n");
|
Added the missing POSIX_NO_YIELD and POSIX_NO_PRIORITIES warning messages.
2000-03-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in: Added the missing POSIX_NO_YIELD and
POSIX_NO_PRIORITIES warning messages.
* configure.in: Use AC_TRY_RUN instead of AC_TRY_LINK, to test for
real thread support. On solaris pthread_create can be linked to
even in -lc, but it doesn't work then.
* configure.in: Don't use priorities for threads, when the
minimal/maximal priorities couldn't be determined at configure
time.
* configure.in, gthread.c: Always define GSystemThread in
glibconfig.h to represent a system thread.
* configure.in: Do not use native recursive threads, when
possibe. We use some features, that they do not expose (namely the
depth counter).
* glib.h, gthread.c: Redefined GStaticRecMutex. The functions are
now implemented in a different way, which should be way
faster. Alsothere are now functions g_static_rec_mutex_unlock_full
and g_static_rec_mutex_lock_full to leave/enter a recursive mutex
completly.
* gthread.c (g_thread_self): Do not test the system_thread to be
non-zero to speed things up.
* gthread.c (g_mutex_init): Therefore set the system_thread of the
main thread here.
* tests/thread-test.c: Rerun all tests once again, but this time
we fool the system into thinking, that the available thread system
is not native, but userprovided.
* gthread/gthread-posix.c: Don't use priorities for threads,
when the minimal/maximal priorities couldn't be determined at
configure time.
* gthread/gthread-posix.c: Don't check for errors, when
setting the scope of a tread to system, as some posix
implementations can't do that and we don't want the thing to
fail because of that.
2000-03-17 15:49:59 +01:00
|
|
|
|
Completed the thread support in GLib. Thread creation, prioritizing
1999-06-17 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* configure.in, acglib.m4, acconfig.h, glib.h, gthread.c:
Completed the thread support in GLib. Thread creation,
prioritizing threads, yielding, joining threads as well as
reader/writer locks and recursive mutexes are now in place. Please
test heavily on your platform. It is so far tested on
Linux/i386/pthreads, Solaris/Sparc/pthreads and
Solaris/Sparc/solaristhreads.
* gtimer.c, glib.h: Implement g_usleep (gulong microseconds) for
thread safe sleeping. (sleep() is not MT-safe at all!)
* gutils.c: Avoid compiler warning.
* tests/Makefile.am, tests/thread-test.c: New program to test some
aspects of the thread implementation.
* gthread.c, Makefile.am: Renamed from gmutex.c to reflect the
change of content.
* configure.in: Purged all appearances of nspr.
* gthread/gthread-posix.c, gthread-solaris.c: Added the native
implementations for the GLib's extended thread support.
* gthread/gthread-nspr.c: Removed for good. NSPR is nothing we
would want to build upon.
* gthread/gthread.c: Renamed to gthread-impl.c to avoid
confusion with ../gthread.c (Formerly known as the file called
gmutex.c)
* gthread/testgthread.c: Removed. The new and much extended
tests are in ../tests/thread-test.c.
* gthread/Makefile.am: Changed to reflect the changes above.
1999-06-17 17:39:31 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|