summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2011-10-02 22:31:45 -0400
committerMatthias Clasen <mclasen@redhat.com>2011-10-02 22:31:45 -0400
commit151756631dcac8e74df37c02bf0cf13d9df2e18b (patch)
tree5a53865803f94610c244cc57d3bc5e99170c3e52 /tests
parent3d4846d92309d001697c2827660fa41b5c63dbc4 (diff)
downloadglib-151756631dcac8e74df37c02bf0cf13d9df2e18b.tar.gz
Don't use g_thread_foreach in tests
Diffstat (limited to 'tests')
-rw-r--r--tests/threadpool-test.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/tests/threadpool-test.c b/tests/threadpool-test.c
index bb96c9e3a..6e1f6fc0e 100644
--- a/tests/threadpool-test.c
+++ b/tests/threadpool-test.c
@@ -81,24 +81,6 @@ test_thread_functions (void)
}
static void
-test_count_threads_foreach (GThread *thread,
- guint *count)
-{
- ++*count;
-}
-
-static guint
-test_count_threads (void)
-{
- guint count = 0;
-
- g_thread_foreach ((GFunc) test_count_threads_foreach, &count);
-
- /* Exclude main thread */
- return count - 1;
-}
-
-static void
test_thread_stop_unused (void)
{
GThreadPool *pool;
@@ -118,16 +100,12 @@ test_thread_stop_unused (void)
/* Wait for the threads to migrate. */
g_usleep (G_USEC_PER_SEC);
- DEBUG_MSG (("[unused] current threads %d",
- test_count_threads()));
-
DEBUG_MSG (("[unused] stopping unused threads"));
g_thread_pool_stop_unused_threads ();
for (i = 0; i < 5; i++)
{
- if (g_thread_pool_get_num_unused_threads () == 0 &&
- test_count_threads () == 0)
+ if (g_thread_pool_get_num_unused_threads () == 0)
break;
DEBUG_MSG (("[unused] waiting ONE second for threads to die"));
@@ -136,11 +114,9 @@ test_thread_stop_unused (void)
g_usleep (G_USEC_PER_SEC);
}
- DEBUG_MSG (("[unused] stopped idle threads, %d remain, %d threads still exist",
- g_thread_pool_get_num_unused_threads (),
- test_count_threads ()));
+ DEBUG_MSG (("[unused] stopped idle threads, %d remain",
+ g_thread_pool_get_num_unused_threads ()));
- g_assert (g_thread_pool_get_num_unused_threads () == test_count_threads ());
g_assert (g_thread_pool_get_num_unused_threads () == 0);
g_thread_pool_set_max_unused_threads (MAX_THREADS);