mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 13:06:14 +01:00
ContextSpecificGroup: some fixups
For all of the effort spent ensuring that this algorithm would be correctly threadsafe, I messed up the order of operations within a single thread when porting to the new approach. Fix that up. Also: fix some overzealous asserting in the testcases. Since shutdown is now lazy, we can never surely say !is_running at any particular point in time.
This commit is contained in:
parent
7a3c8e900a
commit
0de16c98f7
@ -182,10 +182,6 @@ g_context_specific_group_get (GContextSpecificGroup *group,
|
|||||||
if (!group->table)
|
if (!group->table)
|
||||||
group->table = g_hash_table_new (NULL, NULL);
|
group->table = g_hash_table_new (NULL, NULL);
|
||||||
|
|
||||||
/* start only if there are no others */
|
|
||||||
if (start_func && g_hash_table_size (group->table) == 0)
|
|
||||||
g_context_specific_group_request_state (group, TRUE, start_func);
|
|
||||||
|
|
||||||
css = g_hash_table_lookup (group->table, context);
|
css = g_hash_table_lookup (group->table, context);
|
||||||
|
|
||||||
if (!css)
|
if (!css)
|
||||||
@ -202,6 +198,9 @@ g_context_specific_group_get (GContextSpecificGroup *group,
|
|||||||
else
|
else
|
||||||
g_object_ref (css->instance);
|
g_object_ref (css->instance);
|
||||||
|
|
||||||
|
if (start_func)
|
||||||
|
g_context_specific_group_request_state (group, TRUE, start_func);
|
||||||
|
|
||||||
g_mutex_unlock (&group->lock);
|
g_mutex_unlock (&group->lock);
|
||||||
|
|
||||||
return css->instance;
|
return css->instance;
|
||||||
|
@ -313,7 +313,7 @@ test_context_specific_identity (void)
|
|||||||
for (i = 0; i < N_THREADS; i++)
|
for (i = 0; i < N_THREADS; i++)
|
||||||
exited |= GPOINTER_TO_UINT (g_thread_join (threads[i]));
|
exited |= GPOINTER_TO_UINT (g_thread_join (threads[i]));
|
||||||
g_assert (exited);
|
g_assert (exited);
|
||||||
g_assert (!g_atomic_int_get (&is_running));
|
g_assert (!group.requested_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -362,7 +362,6 @@ test_context_specific_emit (void)
|
|||||||
gboolean exited = FALSE;
|
gboolean exited = FALSE;
|
||||||
guint i, n;
|
guint i, n;
|
||||||
|
|
||||||
g_assert (!g_atomic_int_get (&is_running));
|
|
||||||
for (i = 0; i < N_THREADS; i++)
|
for (i = 0; i < N_THREADS; i++)
|
||||||
threads[i] = g_thread_new ("test", test_emit_thread, &observed_values[i]);
|
threads[i] = g_thread_new ("test", test_emit_thread, &observed_values[i]);
|
||||||
|
|
||||||
@ -397,7 +396,7 @@ test_context_specific_emit (void)
|
|||||||
for (i = 0; i < N_THREADS; i++)
|
for (i = 0; i < N_THREADS; i++)
|
||||||
exited |= GPOINTER_TO_UINT (g_thread_join (threads[i]));
|
exited |= GPOINTER_TO_UINT (g_thread_join (threads[i]));
|
||||||
g_assert (exited);
|
g_assert (exited);
|
||||||
g_assert (!g_atomic_int_get (&is_running));
|
g_assert (!group.requested_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user