Ejemplo n.º 1
0
/* note how bad things can happen when the 2 threads both raise and release the
 * wakeup. This is however not a problem because you must always pair a raise
 * with a release */
static inline gboolean
release_wakeup (GstPoll * set)
{
  gboolean result = TRUE;

  if (g_atomic_int_dec_and_test (&set->control_pending)) {
    result = RELEASE_EVENT (set);
  }
  return result;
}
Ejemplo n.º 2
0
static inline gint
release_all_wakeup (GstPoll * set)
{
  gint old;

  while (TRUE) {
    if (!(old = g_atomic_int_get (&set->control_pending)))
      /* nothing pending, just exit */
      break;

    /* try to remove all pending control messages */
    if (g_atomic_int_compare_and_exchange (&set->control_pending, old, 0)) {
      /* we managed to remove all messages, read the control socket */
      if (RELEASE_EVENT (set))
        break;
      else
        /* retry again until we read it successfully */
        g_atomic_int_add (&set->control_pending, 1);
    }
  }
  return old;
}