mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-13 06:00:36 +01:00
Don't use g_thread_foreach in tests
This commit is contained in:
parent
3d4846d923
commit
151756631d
@ -80,24 +80,6 @@ test_thread_functions (void)
|
|||||||
g_assert (g_thread_pool_get_max_idle_time () == 0);
|
g_assert (g_thread_pool_get_max_idle_time () == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
static void
|
||||||
test_thread_stop_unused (void)
|
test_thread_stop_unused (void)
|
||||||
{
|
{
|
||||||
@ -118,16 +100,12 @@ test_thread_stop_unused (void)
|
|||||||
/* Wait for the threads to migrate. */
|
/* Wait for the threads to migrate. */
|
||||||
g_usleep (G_USEC_PER_SEC);
|
g_usleep (G_USEC_PER_SEC);
|
||||||
|
|
||||||
DEBUG_MSG (("[unused] current threads %d",
|
|
||||||
test_count_threads()));
|
|
||||||
|
|
||||||
DEBUG_MSG (("[unused] stopping unused threads"));
|
DEBUG_MSG (("[unused] stopping unused threads"));
|
||||||
g_thread_pool_stop_unused_threads ();
|
g_thread_pool_stop_unused_threads ();
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
if (g_thread_pool_get_num_unused_threads () == 0 &&
|
if (g_thread_pool_get_num_unused_threads () == 0)
|
||||||
test_count_threads () == 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DEBUG_MSG (("[unused] waiting ONE second for threads to die"));
|
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);
|
g_usleep (G_USEC_PER_SEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_MSG (("[unused] stopped idle threads, %d remain, %d threads still exist",
|
DEBUG_MSG (("[unused] stopped idle threads, %d remain",
|
||||||
g_thread_pool_get_num_unused_threads (),
|
g_thread_pool_get_num_unused_threads ()));
|
||||||
test_count_threads ()));
|
|
||||||
|
|
||||||
g_assert (g_thread_pool_get_num_unused_threads () == test_count_threads ());
|
|
||||||
g_assert (g_thread_pool_get_num_unused_threads () == 0);
|
g_assert (g_thread_pool_get_num_unused_threads () == 0);
|
||||||
|
|
||||||
g_thread_pool_set_max_unused_threads (MAX_THREADS);
|
g_thread_pool_set_max_unused_threads (MAX_THREADS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user