Example #1
0
static void
acquire (int nr)
{
  GThread *self;

  self = g_thread_self ();

  if (!g_bit_trylock (&locks[nr], bits[nr]))
    {
      if (g_test_verbose ())
        g_print ("thread %p going to block on lock %d\n", self, nr);
      g_bit_lock (&locks[nr], bits[nr]);
    }

  g_assert (owners[nr] == NULL);   /* hopefully nobody else is here */
  owners[nr] = self;

  /* let some other threads try to ruin our day */
  g_thread_yield ();
  g_thread_yield ();
  g_thread_yield ();

  g_assert (owners[nr] == self);   /* hopefully this is still us... */
  owners[nr] = NULL;               /* make way for the next guy */
  g_bit_unlock (&locks[nr], bits[nr]);
}
Example #2
0
static void
acquire (int nr)
{
  GThread *self;

  self = g_thread_self ();

  g_bit_lock (&locks[nr], bits[nr]);
  g_assert (owners[nr] == NULL);   /* hopefully nobody else is here */
  owners[nr] = self;

  /* let some other threads try to ruin our day */
  g_thread_yield ();
  g_thread_yield ();
  g_thread_yield ();

  g_assert (owners[nr] == self);   /* hopefully this is still us... */
  owners[nr] = NULL;               /* make way for the next guy */
  g_bit_unlock (&locks[nr], bits[nr]);
}
Example #3
0
/* < private >
 * g_variant_unlock:
 * @value: a #GVariant
 *
 * Unlocks @value after performing sensitive operations.
 */
static void
g_variant_unlock (GVariant *value)
{
  g_bit_unlock (&value->state, 0);
}