mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
tests: Fix data races in refcount/closures.c
This commit is contained in:
parent
b09a0df9a9
commit
83221671ea
@ -153,19 +153,11 @@ my_test_class_init (GTestClass *klass)
|
|||||||
klass->test_signal2 = my_test_test_signal2;
|
klass->test_signal2 = my_test_test_signal2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline guint32
|
|
||||||
quick_rand32 (void)
|
|
||||||
{
|
|
||||||
static guint32 accu = 2147483563;
|
|
||||||
accu = 1664525 * accu + 1013904223;
|
|
||||||
return accu;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_closure (GClosure *closure)
|
test_closure (GClosure *closure)
|
||||||
{
|
{
|
||||||
/* try to produce high contention in closure->ref_count */
|
/* try to produce high contention in closure->ref_count */
|
||||||
guint i = 0, n = quick_rand32() % 199;
|
guint i = 0, n = g_random_int () % 199;
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
g_closure_ref (closure);
|
g_closure_ref (closure);
|
||||||
g_closure_sink (closure); /* NOP */
|
g_closure_sink (closure); /* NOP */
|
||||||
|
Loading…
Reference in New Issue
Block a user