From d99b48b2e6f56e61902ed39b304b254a0b7b7ee3 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Fri, 1 Nov 2002 22:17:20 +0000 Subject: [PATCH] Convert to GThreads Original commit message from CVS: Convert to GThreads --- tests/memchunk/gmemchunktest.c | 19 +++++++++++-------- tests/memchunk/gstmemchunktest.c | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/memchunk/gmemchunktest.c b/tests/memchunk/gmemchunktest.c index fe36e1a..074fc24 100644 --- a/tests/memchunk/gmemchunktest.c +++ b/tests/memchunk/gmemchunktest.c @@ -41,15 +41,17 @@ run_test (void *threadid) free_chunk (chunk); } - pthread_exit(NULL); + g_thread_exit(NULL); + return NULL; } gint main (gint argc, gchar *argv[]) { - pthread_t threads[MAX_THREADS]; - int rc, t; + GThread *threads[MAX_THREADS]; + GError *error; + int t; gst_init (&argc, &argv); @@ -65,15 +67,16 @@ main (gint argc, gchar *argv[]) _lock = g_mutex_new (); for(t=0; t < num_threads; t++) { - rc = pthread_create (&threads[t], NULL, run_test, (void *)t); - if (rc) { - printf ("ERROR: return code from pthread_create() is %d\n", rc); - printf ("Code %d= %s\n", rc, strerror(rc)); + error = NULL; + threads[t] = g_thread_create (run_test, (void *)t, TRUE, &error); + if (error) { + printf ("ERROR: g_thread_create () is %s\n", error->message); exit (-1); } } printf ("main(): Created %d threads.\n", t); - pthread_exit (NULL); + g_thread_exit (NULL); g_mem_chunk_info(); + return 0; } diff --git a/tests/memchunk/gstmemchunktest.c b/tests/memchunk/gstmemchunktest.c index 267503e..cade77a 100644 --- a/tests/memchunk/gstmemchunktest.c +++ b/tests/memchunk/gstmemchunktest.c @@ -37,15 +37,17 @@ run_test (void *threadid) free_chunk (chunk); } - pthread_exit(NULL); + g_thread_exit(NULL); + return NULL; } gint main (gint argc, gchar *argv[]) { - pthread_t threads[MAX_THREADS]; - int rc, t; + GThread * threads[MAX_THREADS]; + GError * error; + int t; gst_init (&argc, &argv); @@ -60,17 +62,17 @@ main (gint argc, gchar *argv[]) _chunks = gst_mem_chunk_new ("test", 32, 32 * 16, G_ALLOC_AND_FREE); for(t=0; t < num_threads; t++) { - rc = pthread_create (&threads[t], NULL, run_test, (void *)t); - if (rc) { - printf ("ERROR: return code from pthread_create() is %d\n", rc); - printf ("Code %d= %s\n", rc, strerror(rc)); + error = NULL; + threads[t] = g_thread_create (run_test, (void *)t, TRUE, &error); + if (error) { + printf ("ERROR: g_thread_create() %s\n", error->message); exit (-1); } } printf ("main(): Created %d threads.\n", t); for(t=0; t < num_threads; t++) { - pthread_join (threads[t], NULL); + g_thread_join (threads[t]); } g_mem_chunk_info(); -- 2.7.4