mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Made the debugging G_TRYLOCK call also work for compilers with funnt
2000-04-19 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * glib.h (G_TRYLOCK): Made the debugging G_TRYLOCK call also work for compilers with funnt G_STMT_(START|END) macros. * tests/thread-test.c: Implemented a check for that.
This commit is contained in:
committed by
Sebastian Wilhelmi
parent
e366512775
commit
1383e5b642
@@ -4,12 +4,14 @@
|
||||
|
||||
static GMutex* test_g_mutex_mutex = NULL;
|
||||
static guint test_g_mutex_int = 0;
|
||||
G_LOCK_DEFINE_STATIC (test_g_mutex);
|
||||
|
||||
static void
|
||||
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_TRYLOCK (test_g_mutex) == FALSE);
|
||||
g_mutex_lock (test_g_mutex_mutex);
|
||||
g_assert (test_g_mutex_int == 42);
|
||||
g_mutex_unlock (test_g_mutex_mutex);
|
||||
@@ -22,11 +24,13 @@ test_g_mutex (void)
|
||||
test_g_mutex_mutex = g_mutex_new ();
|
||||
|
||||
g_assert (g_mutex_trylock (test_g_mutex_mutex));
|
||||
g_assert (G_TRYLOCK (test_g_mutex));
|
||||
thread = g_thread_create (test_g_mutex_thread,
|
||||
GINT_TO_POINTER (42),
|
||||
0, TRUE, TRUE, G_THREAD_PRIORITY_NORMAL);
|
||||
g_usleep (G_MICROSEC);
|
||||
test_g_mutex_int = 42;
|
||||
G_UNLOCK (test_g_mutex);
|
||||
g_mutex_unlock (test_g_mutex_mutex);
|
||||
g_thread_join (thread);
|
||||
g_mutex_free (test_g_mutex_mutex);
|
||||
|
Reference in New Issue
Block a user