+/* Unit tests for GMutex
+ * Copyright (C) 2011 Red Hat, Inc
+ * Author: Matthias Clasen
+ *
+ * This work is provided "as is"; redistribution and modification
+ * in whole or in part, in any medium, physical or electronic is
+ * permitted without restriction.
+ *
+ * This work is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * In no event shall the authors or contributors be liable for any
+ * direct, indirect, incidental, special, exemplary, or consequential
+ * damages (including, but not limited to, procurement of substitute
+ * goods or services; loss of use, data, or profits; or business
+ * interruption) however caused and on any theory of liability, whether
+ * in contract, strict liability, or tort (including negligence or
+ * otherwise) arising in any way out of the use of this software, even
+ * if advised of the possibility of such damage.
+ */
+
#include <glib.h>
static void
g_mutex_init (&mutex);
g_mutex_lock (&mutex);
g_mutex_unlock (&mutex);
+ g_mutex_lock (&mutex);
+ g_mutex_unlock (&mutex);
g_mutex_clear (&mutex);
}
g_mutex_lock (&mutex);
g_mutex_unlock (&mutex);
+ g_mutex_lock (&mutex);
+ g_mutex_unlock (&mutex);
g_mutex_clear (&mutex);
}
mutex = g_mutex_new ();
g_mutex_lock (mutex);
g_mutex_unlock (mutex);
+ g_mutex_lock (mutex);
+ g_mutex_unlock (mutex);
g_mutex_free (mutex);
}
ret = g_mutex_trylock (&mutex);
g_assert (ret);
- ret = g_mutex_trylock (&mutex);
/* no guarantees that mutex is recursive, so could return 0 or 1 */
+ if (g_mutex_trylock (&mutex))
+ g_mutex_unlock (&mutex);
g_mutex_unlock (&mutex);
g_mutex_clear (&mutex);
+/* Unit tests for GRecMutex
+ * Copyright (C) 2011 Red Hat, Inc
+ * Author: Matthias Clasen
+ *
+ * This work is provided "as is"; redistribution and modification
+ * in whole or in part, in any medium, physical or electronic is
+ * permitted without restriction.
+ *
+ * This work is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * In no event shall the authors or contributors be liable for any
+ * direct, indirect, incidental, special, exemplary, or consequential
+ * damages (including, but not limited to, procurement of substitute
+ * goods or services; loss of use, data, or profits; or business
+ * interruption) however caused and on any theory of liability, whether
+ * in contract, strict liability, or tort (including negligence or
+ * otherwise) arising in any way out of the use of this software, even
+ * if advised of the possibility of such damage.
+ */
+
#include <glib.h>
static void
g_rec_mutex_init (&mutex);
g_rec_mutex_lock (&mutex);
g_rec_mutex_unlock (&mutex);
+ g_rec_mutex_lock (&mutex);
+ g_rec_mutex_unlock (&mutex);
g_rec_mutex_clear (&mutex);
}
g_rec_mutex_lock (&mutex);
g_rec_mutex_unlock (&mutex);
+ g_rec_mutex_lock (&mutex);
+ g_rec_mutex_unlock (&mutex);
g_rec_mutex_clear (&mutex);
}
g_assert (ret);
g_rec_mutex_unlock (&mutex);
- g_rec_mutex_clear (&mutex);
+ g_rec_mutex_unlock (&mutex);
g_rec_mutex_clear (&mutex);
}