mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
Remove g_mutex_new()/g_cond_new() in testcases
These were the last users of the dynamic allocation API. Keep the uses in glib/tests/mutex.c since this is actually meant to test the API (which has to continue working, even if it is deprecated). https://bugzilla.gnome.org/show_bug.cgi?id=660739
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
/* GMutex */
|
||||
|
||||
static GMutex* test_g_mutex_mutex = NULL;
|
||||
static GMutex test_g_mutex_mutex;
|
||||
static guint test_g_mutex_int = 0;
|
||||
static gboolean test_g_mutex_thread_ready;
|
||||
G_LOCK_DEFINE_STATIC (test_g_mutex);
|
||||
@@ -14,12 +14,12 @@ static gpointer
|
||||
test_g_mutex_thread (gpointer data)
|
||||
{
|
||||
g_assert (GPOINTER_TO_INT (data) == 42);
|
||||
g_assert (g_mutex_trylock (test_g_mutex_mutex) == FALSE);
|
||||
g_assert (g_mutex_trylock (&test_g_mutex_mutex) == FALSE);
|
||||
g_assert (G_TRYLOCK (test_g_mutex) == FALSE);
|
||||
test_g_mutex_thread_ready = TRUE;
|
||||
g_mutex_lock (test_g_mutex_mutex);
|
||||
g_mutex_lock (&test_g_mutex_mutex);
|
||||
g_assert (test_g_mutex_int == 42);
|
||||
g_mutex_unlock (test_g_mutex_mutex);
|
||||
g_mutex_unlock (&test_g_mutex_mutex);
|
||||
|
||||
return GINT_TO_POINTER (41);
|
||||
}
|
||||
@@ -28,9 +28,8 @@ static void
|
||||
test_g_mutex (void)
|
||||
{
|
||||
GThread *thread;
|
||||
test_g_mutex_mutex = g_mutex_new ();
|
||||
|
||||
g_assert (g_mutex_trylock (test_g_mutex_mutex));
|
||||
g_assert (g_mutex_trylock (&test_g_mutex_mutex));
|
||||
g_assert (G_TRYLOCK (test_g_mutex));
|
||||
test_g_mutex_thread_ready = FALSE;
|
||||
thread = g_thread_create (test_g_mutex_thread, GINT_TO_POINTER (42),
|
||||
@@ -41,9 +40,8 @@ test_g_mutex (void)
|
||||
g_usleep (G_USEC_PER_SEC / 5);
|
||||
test_g_mutex_int = 42;
|
||||
G_UNLOCK (test_g_mutex);
|
||||
g_mutex_unlock (test_g_mutex_mutex);
|
||||
g_mutex_unlock (&test_g_mutex_mutex);
|
||||
g_assert (GPOINTER_TO_INT (g_thread_join (thread)) == 41);
|
||||
g_mutex_free (test_g_mutex_mutex);
|
||||
}
|
||||
|
||||
/* GStaticRecMutex */
|
||||
|
Reference in New Issue
Block a user