create a common function for the many places where all nodes in the table
[platform/upstream/glib.git] / glib / gasyncqueue.c
index e025b50..dbaebde 100644 (file)
@@ -313,12 +313,13 @@ g_async_queue_push_sorted_unlocked (GAsyncQueue      *queue,
 }
 
 static gpointer
-g_async_queue_pop_intern_unlocked (GAsyncQueue* queue, gboolean try, 
-                                  GTimeVal *end_time)
+g_async_queue_pop_intern_unlocked (GAsyncQueue *queue, 
+                                  gboolean     try, 
+                                  GTimeVal    *end_time)
 {
   gpointer retval;
 
-  if (!g_queue_peek_tail (queue->queue))
+  if (!g_queue_peek_tail_link (queue->queue))
     {
       if (try)
        return NULL;
@@ -329,18 +330,18 @@ g_async_queue_pop_intern_unlocked (GAsyncQueue* queue, gboolean try,
       if (!end_time)
         {
           queue->waiting_threads++;
-         while (!g_queue_peek_tail (queue->queue))
-            g_cond_wait(queue->cond, queue->mutex);
+         while (!g_queue_peek_tail_link (queue->queue))
+            g_cond_wait (queue->cond, queue->mutex);
           queue->waiting_threads--;
         }
       else
         {
           queue->waiting_threads++;
-          while (!g_queue_peek_tail (queue->queue))
+          while (!g_queue_peek_tail_link (queue->queue))
             if (!g_cond_timed_wait (queue->cond, queue->mutex, end_time))
               break;
           queue->waiting_threads--;
-          if (!g_queue_peek_tail (queue->queue))
+          if (!g_queue_peek_tail_link (queue->queue))
            return NULL;
         }
     }
@@ -564,7 +565,7 @@ g_async_queue_length_unlocked (GAsyncQueue* queue)
  *
  * If you were sorting a list of priority numbers to make sure the
  * lowest priority would be at the top of the queue, you could use:
- * <informalexample><programlisting> 
+ * |[
  *  gint32 id1;
  *  gint32 id2;
  *   
@@ -572,7 +573,7 @@ g_async_queue_length_unlocked (GAsyncQueue* queue)
  *  id2 = GPOINTER_TO_INT (element2);
  *   
  *  return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
- * </programlisting></informalexample>
+ * ]|
  *
  * Since: 2.10
  **/
@@ -624,5 +625,18 @@ g_async_queue_sort_unlocked (GAsyncQueue      *queue,
                &sd);
 }
 
+/*
+ * Private API
+ */
+
+GMutex*
+_g_async_queue_get_mutex (GAsyncQueue* queue)
+{
+  g_return_val_if_fail (queue, NULL);
+  g_return_val_if_fail (g_atomic_int_get (&queue->ref_count) > 0, NULL);
+
+  return queue->mutex;
+}
+
 #define __G_ASYNCQUEUE_C__
 #include "galiasdef.c"